public MonsterCarnival(MapleParty p1, MapleParty p2, int mapid) {
this.p1 = p1;
this.p2 = p2;
int chnl = p1.getLeader().getChannel();
int chnl1 = p2.getLeader().getChannel();
if (chnl != chnl1) throw new RuntimeException("CPQ leaders are on different channels..");
ChannelServer cs = Server.getInstance().getChannel(p1.getLeader().getWorld(), chnl);
p1.setEnemy(p2);
p2.setEnemy(p1);
cs.getMapFactory().disposeMap(mapid);
map = cs.getMapFactory().getMap(mapid);
int redPortal = 0;
int bluePortal = 0;
if (map.isPurpleCPQMap()) {
redPortal = 2;
bluePortal = 1;
}
for (MaplePartyCharacter mpc : p1.getMembers()) {
MapleCharacter mc;
mc = cs.getPlayerStorage().getCharacterByName(mpc.getName());
if (mc != null) {
mc.setMonsterCarnival(this);
mc.changeMap(map, map.getPortal(redPortal));
mc.setTeam(0);
if (p1.getLeader().getId() == mc.getId()) {
leader1 = mc;
}
Grupo1 = mc;
}
}
for (MaplePartyCharacter mpc : p2.getMembers()) {
MapleCharacter mc;
mc = cs.getPlayerStorage().getCharacterByName(mpc.getName());
if (mc != null) {
mc.setMonsterCarnival(this);
mc.changeMap(map, map.getPortal(bluePortal));
mc.setTeam(1);
if (p2.getLeader().getId() == mc.getId()) {
leader2 = mc;
}
Grupo2 = mc;
}
}
Grupo1.getClient().getSession().write(MaplePacketCreator.startCPQ(Grupo1.getTeam(), Grupo1, Grupo2));
Grupo2.getClient().getSession().write(MaplePacketCreator.startCPQ(Grupo2.getTeam(), Grupo2, Grupo1));
startTime = System.currentTimeMillis() + 60 * 10000;
timer = TimerManager.getInstance().schedule(new Runnable() {
public void run() {
timeUp();
}
}, 10 * 60 * 1000);
effectTimer = TimerManager.getInstance().schedule(new Runnable() {
public void run() {
complete();
}
}, 10 * 60 * 1000 - 10 * 1000);
TimerManager.getInstance().schedule(new Runnable() {
public void run() {
map.addClock(60 * 10);
}
}, 2000);
}