Search in sources :

Example 41 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class MapleOxQuiz method sendQuestion.

public void sendQuestion() {
    int gm = 0;
    for (MapleCharacter mc : map.getCharacters()) {
        if (mc.gmLevel() > 1) {
            gm++;
        }
    }
    final int number = gm;
    map.broadcastMessage(MaplePacketCreator.showOXQuiz(round, question, true));
    TimerManager.getInstance().schedule(new Runnable() {

        @Override
        public void run() {
            map.broadcastMessage(MaplePacketCreator.showOXQuiz(round, question, true));
            List<MapleCharacter> chars = new ArrayList<>(map.getCharacters());
            for (MapleCharacter chr : chars) {
                if (// make sure they aren't null... maybe something can happen in 12 seconds.
                chr != null) {
                    if (!isCorrectAnswer(chr, getOXAnswer(round, question)) && !chr.isGM()) {
                        chr.changeMap(chr.getMap().getReturnMap());
                    } else {
                        chr.gainExp(expGain, true, true);
                    }
                }
            }
            // do question
            if ((round == 1 && question == 29) || ((round == 2 || round == 3) && question == 17) || ((round == 4 || round == 8) && question == 12) || (round == 5 && question == 26) || (round == 9 && question == 44) || ((round == 6 || round == 7) && question == 16)) {
                question = 100;
            } else {
                question++;
            }
            // send question
            if (map.getCharacters().size() - number <= 2) {
                map.broadcastMessage(MaplePacketCreator.serverNotice(6, "The event has ended"));
                map.getPortal("join00").setPortalStatus(true);
                map.setOx(null);
                map.setOxQuiz(false);
                // prizes here
                return;
            }
            sendQuestion();
        }
    }, // Time to answer = 30 seconds ( Ox Quiz packet shows a 30 second timer.
    30000);
}
Also used : MapleCharacter(client.MapleCharacter) List(java.util.List) ArrayList(java.util.ArrayList)

Example 42 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class MonsterCarnival method saveResults.

public void saveResults() {
    Connection con = null;
    try {
        con = DatabaseConnection.getConnection();
        PreparedStatement ps = con.prepareStatement("INSERT INTO carnivalresults VALUES (?,?,?,?)");
        for (MapleCharacter chr : red.getMembers()) {
            ps.setInt(1, chr.getId());
            ps.setInt(2, chr.getCP());
            ps.setInt(3, red.getTotalCP());
            ps.setInt(4, red.isWinner() ? 1 : 0);
            ps.execute();
        }
        for (MapleCharacter chr : blue.getMembers()) {
            ps.setInt(1, chr.getId());
            ps.setInt(2, chr.getCP());
            ps.setInt(3, blue.getTotalCP());
            ps.setInt(4, blue.isWinner() ? 1 : 0);
            ps.execute();
        }
        ps.close();
        con.close();
    } catch (SQLException ex) {
        ex.printStackTrace();
    }
}
Also used : MapleCharacter(client.MapleCharacter) SQLException(java.sql.SQLException) DatabaseConnection(tools.DatabaseConnection) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement)

Example 43 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class SpawnPoint method getMonster.

public MapleMonster getMonster() {
    MapleMonster mob = new MapleMonster(MapleLifeFactory.getMonster(monster));
    mob.setPosition(new Point(pos));
    mob.setTeam(team);
    mob.setFh(fh);
    mob.setF(f);
    spawnedMonsters.incrementAndGet();
    mob.addListener(new MonsterListener() {

        @Override
        public void monsterKilled(int aniTime) {
            nextPossibleSpawn = System.currentTimeMillis();
            if (mobTime > 0) {
                nextPossibleSpawn += mobTime * 1000;
            } else {
                nextPossibleSpawn += aniTime;
            }
            spawnedMonsters.decrementAndGet();
        }

        @Override
        public void monsterDamaged(MapleCharacter from, int trueDmg) {
        }

        @Override
        public void monsterHealed(int trueHeal) {
        }
    });
    if (mobTime == 0) {
        nextPossibleSpawn = System.currentTimeMillis() + mobInterval;
    }
    return mob;
}
Also used : MapleCharacter(client.MapleCharacter) Point(java.awt.Point) Point(java.awt.Point)

Example 44 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class Channel method startDojoSchedule.

public void startDojoSchedule(final int dojoMapId) {
    final int slot = getDojoSlot(dojoMapId);
    final int stage = (dojoMapId / 100) % 100;
    if (stage <= dojoStage[slot])
        return;
    long clockTime = (stage > 36 ? 15 : (stage / 6) + 5) * 60000;
    this.dojoTask[slot] = TimerManager.getInstance().schedule(new Runnable() {

        @Override
        public void run() {
            final int delta = (dojoMapId) % 100;
            final int dojoBaseMap = (slot < 5) ? 925030000 : 925020000;
            MapleParty party = null;
            for (int i = 0; i < 5; i++) {
                // only 32 stages, but 38 maps
                for (MapleCharacter chr : getMapFactory().getMap(dojoBaseMap + (100 * (stage + i)) + delta).getAllPlayers()) {
                    if (chr.getMap().isDojoMap()) {
                        chr.timeoutFromDojo();
                    }
                    party = chr.getParty();
                }
            }
            freeDojoSlot(slot, party);
        }
    }, // let the TIMES UP display for 3 seconds, then warp
    clockTime + 3000);
    dojoFinishTime[slot] = System.currentTimeMillis() + clockTime;
}
Also used : MapleCharacter(client.MapleCharacter) MapleParty(net.server.world.MapleParty)

Example 45 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class AllianceOperationHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    MapleAlliance alliance = null;
    MapleCharacter chr = c.getPlayer();
    if (chr.getGuild() == null) {
        c.announce(MaplePacketCreator.enableActions());
        return;
    }
    if (chr.getGuild().getAllianceId() > 0) {
        alliance = chr.getAlliance();
    }
    byte b = slea.readByte();
    if (alliance == null) {
        if (b != 4) {
            c.announce(MaplePacketCreator.enableActions());
            return;
        }
    } else {
        if (b == 4) {
            chr.dropMessage("Your guild is already registered on a Guild Alliance.");
            c.announce(MaplePacketCreator.enableActions());
            return;
        }
        if (chr.getMGC().getAllianceRank() > 2 || !alliance.getGuilds().contains(chr.getGuildId())) {
            c.announce(MaplePacketCreator.enableActions());
            return;
        }
    }
    // "alliance" is only null at case 0x04
    switch(b) {
        case 0x01:
            Server.getInstance().allianceMessage(alliance.getId(), sendShowInfo(chr.getGuild().getAllianceId(), chr.getId()), -1, -1);
            break;
        case 0x02:
            {
                // Leave Alliance
                if (chr.getGuild().getAllianceId() == 0 || chr.getGuildId() < 1 || chr.getGuildRank() != 1) {
                    return;
                }
                MapleAlliance.removeGuildFromAlliance(chr.getGuild().getAllianceId(), chr.getGuildId(), chr.getWorld());
                break;
            }
        case // Send Invite
        0x03:
            String guildName = slea.readMapleAsciiString();
            if (alliance.getGuilds().size() == alliance.getCapacity()) {
                chr.dropMessage("Your alliance cannot comport any more guilds at the moment.");
            } else {
                MapleGuild mg = Server.getInstance().getGuildByName(guildName);
                if (mg == null) {
                    chr.dropMessage("The entered guild does not exist.");
                } else {
                    MapleCharacter victim = mg.getMGC(mg.getLeaderId()).getCharacter();
                    if (victim == null) {
                        chr.dropMessage("The master of the guild that you offered an invitation is currently not online.");
                    } else {
                        victim.getClient().announce(MaplePacketCreator.sendAllianceInvitation(alliance.getId(), chr));
                    }
                }
            }
            break;
        case 0x04:
            {
                // Accept Invite
                if (chr.getGuild().getAllianceId() != 0 || chr.getGuildRank() != 1 || chr.getGuildId() < 1) {
                    return;
                }
                int allianceid = slea.readInt();
                // slea.readMapleAsciiString();  //recruiter's guild name
                alliance = Server.getInstance().getAlliance(allianceid);
                if (alliance == null) {
                    return;
                }
                int guildid = chr.getGuildId();
                Server.getInstance().addGuildtoAlliance(alliance.getId(), guildid);
                Server.getInstance().resetAllianceGuildPlayersRank(guildid);
                chr.getMGC().setAllianceRank(2);
                Server.getInstance().getGuild(chr.getGuildId()).getMGC(chr.getId()).setAllianceRank(2);
                chr.saveGuildStatus();
                Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.addGuildToAlliance(alliance, guildid, c), -1, -1);
                Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.updateAllianceInfo(alliance, c), -1, -1);
                Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.allianceNotice(alliance.getId(), alliance.getNotice()), -1, -1);
                chr.getGuild().dropMessage("Your guild has joined the [" + alliance.getName() + "] union.");
                break;
            }
        case 0x06:
            {
                // Expel Guild
                int guildid = slea.readInt();
                int allianceid = slea.readInt();
                if (chr.getGuild().getAllianceId() == 0 || chr.getGuild().getAllianceId() != allianceid) {
                    return;
                }
                Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.removeGuildFromAlliance(alliance, guildid, c.getWorld()), -1, -1);
                Server.getInstance().removeGuildFromAlliance(alliance.getId(), guildid);
                Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, c.getWorld()), -1, -1);
                Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.allianceNotice(alliance.getId(), alliance.getNotice()), -1, -1);
                Server.getInstance().guildMessage(guildid, MaplePacketCreator.disbandAlliance(allianceid));
                alliance.dropMessage("[" + Server.getInstance().getGuild(guildid).getName() + "] guild has been expelled from the union.");
                break;
            }
        case 0x07:
            {
                // Change Alliance Leader
                if (chr.getGuild().getAllianceId() == 0 || chr.getGuildId() < 1) {
                    return;
                }
                int victimid = slea.readInt();
                MapleCharacter player = Server.getInstance().getWorld(c.getWorld()).getPlayerStorage().getCharacterById(victimid);
                if (player.getAllianceRank() != 2) {
                    return;
                }
                // Server.getInstance().allianceMessage(alliance.getId(), sendChangeLeader(chr.getGuild().getAllianceId(), chr.getId(), slea.readInt()), -1, -1);
                changeLeaderAllianceRank(alliance, player);
                break;
            }
        case 0x08:
            String[] ranks = new String[5];
            for (int i = 0; i < 5; i++) {
                ranks[i] = slea.readMapleAsciiString();
            }
            Server.getInstance().setAllianceRanks(alliance.getId(), ranks);
            Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.changeAllianceRankTitle(alliance.getId(), ranks), -1, -1);
            break;
        case 0x09:
            {
                int int1 = slea.readInt();
                byte byte1 = slea.readByte();
                // Server.getInstance().allianceMessage(alliance.getId(), sendChangeRank(chr.getGuild().getAllianceId(), chr.getId(), int1, byte1), -1, -1);
                MapleCharacter player = Server.getInstance().getWorld(c.getWorld()).getPlayerStorage().getCharacterById(int1);
                changePlayerAllianceRank(alliance, player, (byte1 > 0));
                break;
            }
        case 0x0A:
            String notice = slea.readMapleAsciiString();
            Server.getInstance().setAllianceNotice(alliance.getId(), notice);
            Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.allianceNotice(alliance.getId(), notice), -1, -1);
            alliance.dropMessage(5, "* Alliance Notice : " + notice);
            break;
        default:
            chr.dropMessage("Feature not available");
    }
    alliance.saveToDB();
}
Also used : MapleCharacter(client.MapleCharacter) MapleAlliance(net.server.guild.MapleAlliance) MapleGuild(net.server.guild.MapleGuild)

Aggregations

MapleCharacter (client.MapleCharacter)163 Point (java.awt.Point)32 SQLException (java.sql.SQLException)22 Item (client.inventory.Item)21 Connection (java.sql.Connection)15 PreparedStatement (java.sql.PreparedStatement)15 MapleMonster (server.life.MapleMonster)15 MapleMapObject (server.maps.MapleMapObject)15 DatabaseConnection (tools.DatabaseConnection)15 MapleMap (server.maps.MapleMap)14 ArrayList (java.util.ArrayList)13 Skill (client.Skill)12 SpawnPoint (server.life.SpawnPoint)12 LinkedList (java.util.LinkedList)11 MapleInventory (client.inventory.MapleInventory)10 World (net.server.world.World)10 MapleStatEffect (server.MapleStatEffect)10 MapleInventoryType (client.inventory.MapleInventoryType)9 ResultSet (java.sql.ResultSet)9 MapleItemInformationProvider (server.MapleItemInformationProvider)9