Rename and clean up MapleMiniGame
This commit is contained in:
@@ -68,7 +68,7 @@ import server.life.MobSkillFactory;
|
|||||||
import server.life.Monster;
|
import server.life.Monster;
|
||||||
import server.life.PlayerNPC;
|
import server.life.PlayerNPC;
|
||||||
import server.maps.*;
|
import server.maps.*;
|
||||||
import server.maps.MapleMiniGame.MiniGameResult;
|
import server.maps.MiniGame.MiniGameResult;
|
||||||
import server.minigame.MapleRockPaperScissor;
|
import server.minigame.MapleRockPaperScissor;
|
||||||
import server.partyquest.AriantColiseum;
|
import server.partyquest.AriantColiseum;
|
||||||
import server.partyquest.MonsterCarnival;
|
import server.partyquest.MonsterCarnival;
|
||||||
@@ -158,7 +158,7 @@ public class Character extends AbstractCharacterObject {
|
|||||||
private Inventory[] inventory;
|
private Inventory[] inventory;
|
||||||
private Job job = Job.BEGINNER;
|
private Job job = Job.BEGINNER;
|
||||||
private Messenger messenger = null;
|
private Messenger messenger = null;
|
||||||
private MapleMiniGame miniGame;
|
private MiniGame miniGame;
|
||||||
private MapleRockPaperScissor rps;
|
private MapleRockPaperScissor rps;
|
||||||
private Mount maplemount;
|
private Mount maplemount;
|
||||||
private Party party;
|
private Party party;
|
||||||
@@ -5338,7 +5338,7 @@ public class Character extends AbstractCharacterObject {
|
|||||||
setTargetHpBarTime(0);
|
setTargetHpBarTime(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapleMiniGame getMiniGame() {
|
public MiniGame getMiniGame() {
|
||||||
return miniGame;
|
return miniGame;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5562,7 +5562,7 @@ public class Character extends AbstractCharacterObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void closeMiniGame(boolean forceClose) {
|
public void closeMiniGame(boolean forceClose) {
|
||||||
MapleMiniGame game = this.getMiniGame();
|
MiniGame game = this.getMiniGame();
|
||||||
if (game == null) {
|
if (game == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -9180,7 +9180,7 @@ public class Character extends AbstractCharacterObject {
|
|||||||
this.messengerposition = position;
|
this.messengerposition = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMiniGame(MapleMiniGame miniGame) {
|
public void setMiniGame(MiniGame miniGame) {
|
||||||
this.miniGame = miniGame;
|
this.miniGame = miniGame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import net.packet.InPacket;
|
|||||||
import server.MapleItemInformationProvider;
|
import server.MapleItemInformationProvider;
|
||||||
import server.MapleTrade;
|
import server.MapleTrade;
|
||||||
import server.maps.*;
|
import server.maps.*;
|
||||||
import server.maps.MapleMiniGame.MiniGameType;
|
import server.maps.MiniGame.MiniGameType;
|
||||||
import tools.FilePrinter;
|
import tools.FilePrinter;
|
||||||
import tools.PacketCreator;
|
import tools.PacketCreator;
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapleMiniGame game = new MapleMiniGame(chr, desc, pw);
|
MiniGame game = new MiniGame(chr, desc, pw);
|
||||||
chr.setMiniGame(game);
|
chr.setMiniGame(game);
|
||||||
game.setPieceType(type);
|
game.setPieceType(type);
|
||||||
game.setGameType(MiniGameType.OMOK);
|
game.setGameType(MiniGameType.OMOK);
|
||||||
@@ -206,7 +206,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapleMiniGame game = new MapleMiniGame(chr, desc, pw);
|
MiniGame game = new MiniGame(chr, desc, pw);
|
||||||
game.setPieceType(type);
|
game.setPieceType(type);
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
game.setMatchesToWin(6);
|
game.setMatchesToWin(6);
|
||||||
@@ -285,11 +285,11 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
if (ob instanceof MaplePlayerShop) {
|
if (ob instanceof MaplePlayerShop) {
|
||||||
MaplePlayerShop shop = (MaplePlayerShop) ob;
|
MaplePlayerShop shop = (MaplePlayerShop) ob;
|
||||||
shop.visitShop(chr);
|
shop.visitShop(chr);
|
||||||
} else if (ob instanceof MapleMiniGame) {
|
} else if (ob instanceof MiniGame) {
|
||||||
p.skip(1);
|
p.skip(1);
|
||||||
String pw = p.available() > 1 ? p.readString() : "";
|
String pw = p.available() > 1 ? p.readString() : "";
|
||||||
|
|
||||||
MapleMiniGame game = (MapleMiniGame) ob;
|
MiniGame game = (MiniGame) ob;
|
||||||
if(game.checkPassword(pw)) {
|
if(game.checkPassword(pw)) {
|
||||||
if (game.hasFreeSlot() && !game.isVisitor(chr)) {
|
if (game.hasFreeSlot() && !game.isVisitor(chr)) {
|
||||||
game.addVisitor(chr);
|
game.addVisitor(chr);
|
||||||
@@ -323,7 +323,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
shop.chat(c, p.readString());
|
shop.chat(c, p.readString());
|
||||||
}
|
}
|
||||||
} else if (chr.getMiniGame() != null) {
|
} else if (chr.getMiniGame() != null) {
|
||||||
MapleMiniGame game = chr.getMiniGame();
|
MiniGame game = chr.getMiniGame();
|
||||||
if (game != null) {
|
if (game != null) {
|
||||||
game.chat(c, p.readString());
|
game.chat(c, p.readString());
|
||||||
}
|
}
|
||||||
@@ -377,13 +377,13 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
chr.getMap().broadcastMessage(PacketCreator.spawnHiredMerchantBox(merchant));
|
chr.getMap().broadcastMessage(PacketCreator.spawnHiredMerchantBox(merchant));
|
||||||
}
|
}
|
||||||
} else if (mode == Action.READY.getCode()) {
|
} else if (mode == Action.READY.getCode()) {
|
||||||
MapleMiniGame game = chr.getMiniGame();
|
MiniGame game = chr.getMiniGame();
|
||||||
game.broadcast(PacketCreator.getMiniGameReady(game));
|
game.broadcast(PacketCreator.getMiniGameReady(game));
|
||||||
} else if (mode == Action.UN_READY.getCode()) {
|
} else if (mode == Action.UN_READY.getCode()) {
|
||||||
MapleMiniGame game = chr.getMiniGame();
|
MiniGame game = chr.getMiniGame();
|
||||||
game.broadcast(PacketCreator.getMiniGameUnReady(game));
|
game.broadcast(PacketCreator.getMiniGameUnReady(game));
|
||||||
} else if (mode == Action.START.getCode()) {
|
} else if (mode == Action.START.getCode()) {
|
||||||
MapleMiniGame game = chr.getMiniGame();
|
MiniGame game = chr.getMiniGame();
|
||||||
if (game.getGameType().equals(MiniGameType.OMOK)) {
|
if (game.getGameType().equals(MiniGameType.OMOK)) {
|
||||||
game.minigameMatchStarted();
|
game.minigameMatchStarted();
|
||||||
game.broadcast(PacketCreator.getMiniGameStart(game, game.getLoser()));
|
game.broadcast(PacketCreator.getMiniGameStart(game, game.getLoser()));
|
||||||
@@ -395,7 +395,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
chr.getMap().broadcastMessage(PacketCreator.addMatchCardBox(game.getOwner(), 2, 1));
|
chr.getMap().broadcastMessage(PacketCreator.addMatchCardBox(game.getOwner(), 2, 1));
|
||||||
}
|
}
|
||||||
} else if (mode == Action.GIVE_UP.getCode()) {
|
} else if (mode == Action.GIVE_UP.getCode()) {
|
||||||
MapleMiniGame game = chr.getMiniGame();
|
MiniGame game = chr.getMiniGame();
|
||||||
if (game.getGameType().equals(MiniGameType.OMOK)) {
|
if (game.getGameType().equals(MiniGameType.OMOK)) {
|
||||||
if (game.isOwner(chr)) {
|
if (game.isOwner(chr)) {
|
||||||
game.minigameMatchVisitorWins(true);
|
game.minigameMatchVisitorWins(true);
|
||||||
@@ -410,7 +410,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (mode == Action.REQUEST_TIE.getCode()) {
|
} else if (mode == Action.REQUEST_TIE.getCode()) {
|
||||||
MapleMiniGame game = chr.getMiniGame();
|
MiniGame game = chr.getMiniGame();
|
||||||
if (!game.isTieDenied(chr)) {
|
if (!game.isTieDenied(chr)) {
|
||||||
if (game.isOwner(chr)) {
|
if (game.isOwner(chr)) {
|
||||||
game.broadcastToVisitor(PacketCreator.getMiniGameRequestTie(game));
|
game.broadcastToVisitor(PacketCreator.getMiniGameRequestTie(game));
|
||||||
@@ -419,7 +419,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (mode == Action.ANSWER_TIE.getCode()) {
|
} else if (mode == Action.ANSWER_TIE.getCode()) {
|
||||||
MapleMiniGame game = chr.getMiniGame();
|
MiniGame game = chr.getMiniGame();
|
||||||
if (p.readByte() != 0) {
|
if (p.readByte() != 0) {
|
||||||
game.minigameMatchDraw();
|
game.minigameMatchDraw();
|
||||||
} else {
|
} else {
|
||||||
@@ -432,7 +432,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (mode == Action.SKIP.getCode()) {
|
} else if (mode == Action.SKIP.getCode()) {
|
||||||
MapleMiniGame game = chr.getMiniGame();
|
MiniGame game = chr.getMiniGame();
|
||||||
if (game.isOwner(chr)) {
|
if (game.isOwner(chr)) {
|
||||||
game.broadcast(PacketCreator.getMiniGameSkipOwner(game));
|
game.broadcast(PacketCreator.getMiniGameSkipOwner(game));
|
||||||
} else {
|
} else {
|
||||||
@@ -446,7 +446,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
} else if (mode == Action.SELECT_CARD.getCode()) {
|
} else if (mode == Action.SELECT_CARD.getCode()) {
|
||||||
int turn = p.readByte(); // 1st turn = 1; 2nd turn = 0
|
int turn = p.readByte(); // 1st turn = 1; 2nd turn = 0
|
||||||
int slot = p.readByte(); // slot
|
int slot = p.readByte(); // slot
|
||||||
MapleMiniGame game = chr.getMiniGame();
|
MiniGame game = chr.getMiniGame();
|
||||||
int firstslot = game.getFirstSlot();
|
int firstslot = game.getFirstSlot();
|
||||||
if (turn == 1) {
|
if (turn == 1) {
|
||||||
game.setFirstSlot(slot);
|
game.setFirstSlot(slot);
|
||||||
@@ -758,7 +758,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
shop.banPlayer(p.readString());
|
shop.banPlayer(p.readString());
|
||||||
}
|
}
|
||||||
} else if (mode == Action.EXPEL.getCode()) {
|
} else if (mode == Action.EXPEL.getCode()) {
|
||||||
MapleMiniGame miniGame = chr.getMiniGame();
|
MiniGame miniGame = chr.getMiniGame();
|
||||||
if(miniGame != null && miniGame.isOwner(chr)) {
|
if(miniGame != null && miniGame.isOwner(chr)) {
|
||||||
Character visitor = miniGame.getVisitor();
|
Character visitor = miniGame.getVisitor();
|
||||||
|
|
||||||
@@ -768,12 +768,12 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (mode == Action.EXIT_AFTER_GAME.getCode()) {
|
} else if (mode == Action.EXIT_AFTER_GAME.getCode()) {
|
||||||
MapleMiniGame miniGame = chr.getMiniGame();
|
MiniGame miniGame = chr.getMiniGame();
|
||||||
if(miniGame != null) {
|
if(miniGame != null) {
|
||||||
miniGame.setQuitAfterGame(chr, true);
|
miniGame.setQuitAfterGame(chr, true);
|
||||||
}
|
}
|
||||||
} else if (mode == Action.CANCEL_EXIT_AFTER_GAME.getCode()) {
|
} else if (mode == Action.CANCEL_EXIT_AFTER_GAME.getCode()) {
|
||||||
MapleMiniGame miniGame = chr.getMiniGame();
|
MiniGame miniGame = chr.getMiniGame();
|
||||||
if(miniGame != null) {
|
if(miniGame != null) {
|
||||||
miniGame.setQuitAfterGame(chr, false);
|
miniGame.setQuitAfterGame(chr, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,22 +32,21 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Matze
|
* @author Matze
|
||||||
* @author Ronan (HeavenMS)
|
* @author Ronan (HeavenMS)
|
||||||
*/
|
*/
|
||||||
public class MapleMiniGame extends AbstractMapObject {
|
public class MiniGame extends AbstractMapObject {
|
||||||
private Character owner;
|
private Character owner;
|
||||||
private Character visitor;
|
private Character visitor;
|
||||||
private String password;
|
private final String password;
|
||||||
private MiniGameType GameType = MiniGameType.UNDEFINED;
|
private MiniGameType GameType = MiniGameType.UNDEFINED;
|
||||||
private int piecetype;
|
private int piecetype;
|
||||||
private int inprogress = 0;
|
private int inprogress = 0;
|
||||||
private int[] piece = new int[250];
|
private final int[] piece = new int[250];
|
||||||
private List<Integer> list4x3 = new ArrayList<>();
|
private final List<Integer> list4x3 = new ArrayList<>();
|
||||||
private List<Integer> list5x4 = new ArrayList<>();
|
private final List<Integer> list5x4 = new ArrayList<>();
|
||||||
private List<Integer> list6x5 = new ArrayList<>();
|
private final List<Integer> list6x5 = new ArrayList<>();
|
||||||
private String description;
|
private final String description;
|
||||||
private int loser = 1;
|
private int loser = 1;
|
||||||
private int firstslot = 0;
|
private int firstslot = 0;
|
||||||
private int visitorpoints = 0, visitorscore = 0, visitorforfeits = 0, lastvisitor = -1;
|
private int visitorpoints = 0, visitorscore = 0, visitorforfeits = 0, lastvisitor = -1;
|
||||||
@@ -56,24 +55,24 @@ public class MapleMiniGame extends AbstractMapObject {
|
|||||||
private long nextavailabletie = 0;
|
private long nextavailabletie = 0;
|
||||||
private int matchestowin = 0;
|
private int matchestowin = 0;
|
||||||
|
|
||||||
public static enum MiniGameType {
|
public enum MiniGameType {
|
||||||
UNDEFINED(0), OMOK(1), MATCH_CARD(2);
|
UNDEFINED(0), OMOK(1), MATCH_CARD(2);
|
||||||
private int value = 0;
|
private int value = 0;
|
||||||
|
|
||||||
private MiniGameType(int value) {
|
MiniGameType(int value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getValue() {
|
public int getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum MiniGameResult {
|
public enum MiniGameResult {
|
||||||
WIN, LOSS, TIE
|
WIN, LOSS, TIE
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapleMiniGame(Character owner, String description, String password) {
|
public MiniGame(Character owner, String description, String password) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
@@ -82,11 +81,11 @@ public class MapleMiniGame extends AbstractMapObject {
|
|||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
return this.password;
|
return this.password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkPassword(String sentPw) {
|
public boolean checkPassword(String sentPw) {
|
||||||
return this.password.length() == 0 || sentPw.toLowerCase().contentEquals(this.password.toLowerCase());
|
return this.password.length() == 0 || sentPw.toLowerCase().contentEquals(this.password.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasFreeSlot() {
|
public boolean hasFreeSlot() {
|
||||||
return visitor == null;
|
return visitor == null;
|
||||||
}
|
}
|
||||||
@@ -94,18 +93,18 @@ public class MapleMiniGame extends AbstractMapObject {
|
|||||||
public boolean isOwner(Character chr) {
|
public boolean isOwner(Character chr) {
|
||||||
return owner.equals(chr);
|
return owner.equals(chr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addVisitor(Character challenger) {
|
public void addVisitor(Character challenger) {
|
||||||
visitor = challenger;
|
visitor = challenger;
|
||||||
if (lastvisitor != challenger.getId()) {
|
if (lastvisitor != challenger.getId()) {
|
||||||
ownerscore = 0;
|
ownerscore = 0;
|
||||||
ownerforfeits = 0;
|
ownerforfeits = 0;
|
||||||
|
|
||||||
visitorscore = 0;
|
visitorscore = 0;
|
||||||
visitorforfeits = 0;
|
visitorforfeits = 0;
|
||||||
lastvisitor = challenger.getId();
|
lastvisitor = challenger.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
Character owner = this.getOwner();
|
Character owner = this.getOwner();
|
||||||
if (GameType == MiniGameType.OMOK) {
|
if (GameType == MiniGameType.OMOK) {
|
||||||
owner.sendPacket(PacketCreator.getMiniGameNewVisitor(this, challenger, 1));
|
owner.sendPacket(PacketCreator.getMiniGameNewVisitor(this, challenger, 1));
|
||||||
@@ -115,20 +114,20 @@ public class MapleMiniGame extends AbstractMapObject {
|
|||||||
owner.getMap().broadcastMessage(PacketCreator.addMatchCardBox(owner, 2, 0));
|
owner.getMap().broadcastMessage(PacketCreator.addMatchCardBox(owner, 2, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeRoom(boolean forceClose) {
|
public void closeRoom(boolean forceClose) {
|
||||||
owner.getMap().broadcastMessage(PacketCreator.removeMinigameBox(owner));
|
owner.getMap().broadcastMessage(PacketCreator.removeMinigameBox(owner));
|
||||||
|
|
||||||
if (forceClose) {
|
if (forceClose) {
|
||||||
this.broadcastToOwner(PacketCreator.getMiniGameClose(false, 4));
|
this.broadcastToOwner(PacketCreator.getMiniGameClose(false, 4));
|
||||||
}
|
}
|
||||||
this.broadcastToVisitor(PacketCreator.getMiniGameClose(true, 3));
|
this.broadcastToVisitor(PacketCreator.getMiniGameClose(true, 3));
|
||||||
|
|
||||||
if (visitor != null) {
|
if (visitor != null) {
|
||||||
visitor.setMiniGame(null);
|
visitor.setMiniGame(null);
|
||||||
visitor = null;
|
visitor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
owner.setMiniGame(null);
|
owner.setMiniGame(null);
|
||||||
owner = null;
|
owner = null;
|
||||||
}
|
}
|
||||||
@@ -138,10 +137,10 @@ public class MapleMiniGame extends AbstractMapObject {
|
|||||||
if (forceClose) {
|
if (forceClose) {
|
||||||
visitor.sendPacket(PacketCreator.getMiniGameClose(true, 4));
|
visitor.sendPacket(PacketCreator.getMiniGameClose(true, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
challenger.setMiniGame(null);
|
challenger.setMiniGame(null);
|
||||||
visitor = null;
|
visitor = null;
|
||||||
|
|
||||||
this.getOwner().sendPacket(PacketCreator.getMiniGameRemoveVisitor());
|
this.getOwner().sendPacket(PacketCreator.getMiniGameRemoveVisitor());
|
||||||
if (GameType == MiniGameType.OMOK) {
|
if (GameType == MiniGameType.OMOK) {
|
||||||
this.getOwner().getMap().broadcastMessage(PacketCreator.addOmokBox(owner, 1, 0));
|
this.getOwner().getMap().broadcastMessage(PacketCreator.addOmokBox(owner, 1, 0));
|
||||||
@@ -161,7 +160,7 @@ public class MapleMiniGame extends AbstractMapObject {
|
|||||||
c.sendPacket(packet);
|
c.sendPacket(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void broadcastToVisitor(Packet packet) {
|
public void broadcastToVisitor(Packet packet) {
|
||||||
if (visitor != null) {
|
if (visitor != null) {
|
||||||
visitor.sendPacket(packet);
|
visitor.sendPacket(packet);
|
||||||
@@ -179,7 +178,7 @@ public class MapleMiniGame extends AbstractMapObject {
|
|||||||
private void updateMiniGameBox() {
|
private void updateMiniGameBox() {
|
||||||
this.getOwner().getMap().broadcastMessage(PacketCreator.addOmokBox(owner, visitor != null ? 2 : 1, inprogress));
|
this.getOwner().getMap().broadcastMessage(PacketCreator.addOmokBox(owner, visitor != null ? 2 : 1, inprogress));
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized boolean minigameMatchFinish() {
|
private synchronized boolean minigameMatchFinish() {
|
||||||
if (isMatchInProgress()) {
|
if (isMatchInProgress()) {
|
||||||
inprogress = 0;
|
inprogress = 0;
|
||||||
@@ -188,23 +187,23 @@ public class MapleMiniGame extends AbstractMapObject {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void minigameMatchFinished() {
|
private void minigameMatchFinished() {
|
||||||
updateMiniGameBox();
|
updateMiniGameBox();
|
||||||
|
|
||||||
if (ownerquit) {
|
if (ownerquit) {
|
||||||
owner.closeMiniGame(true);
|
owner.closeMiniGame(true);
|
||||||
} else if (visitorquit) {
|
} else if (visitorquit) {
|
||||||
visitor.closeMiniGame(true);
|
visitor.closeMiniGame(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void minigameMatchStarted() {
|
public void minigameMatchStarted() {
|
||||||
inprogress = 1;
|
inprogress = 1;
|
||||||
ownerquit = false;
|
ownerquit = false;
|
||||||
visitorquit = false;
|
visitorquit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setQuitAfterGame(Character player, boolean quit) {
|
public void setQuitAfterGame(Character player, boolean quit) {
|
||||||
if (isOwner(player)) {
|
if (isOwner(player)) {
|
||||||
ownerquit = quit;
|
ownerquit = quit;
|
||||||
@@ -212,11 +211,11 @@ public class MapleMiniGame extends AbstractMapObject {
|
|||||||
visitorquit = quit;
|
visitorquit = quit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMatchInProgress() {
|
public boolean isMatchInProgress() {
|
||||||
return inprogress != 0;
|
return inprogress != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void denyTie(Character chr) {
|
public void denyTie(Character chr) {
|
||||||
if (this.isOwner(chr)) {
|
if (this.isOwner(chr)) {
|
||||||
inprogress |= (1 << 1);
|
inprogress |= (1 << 1);
|
||||||
@@ -224,7 +223,7 @@ public class MapleMiniGame extends AbstractMapObject {
|
|||||||
inprogress |= (1 << 2);
|
inprogress |= (1 << 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTieDenied(Character chr) {
|
public boolean isTieDenied(Character chr) {
|
||||||
if (this.isOwner(chr)) {
|
if (this.isOwner(chr)) {
|
||||||
return ((inprogress >> 2) % 2) == 1;
|
return ((inprogress >> 2) % 2) == 1;
|
||||||
@@ -232,53 +231,67 @@ public class MapleMiniGame extends AbstractMapObject {
|
|||||||
return ((inprogress >> 1) % 2) == 1;
|
return ((inprogress >> 1) % 2) == 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void minigameMatchOwnerWins(boolean forfeit) {
|
public void minigameMatchOwnerWins(boolean forfeit) {
|
||||||
if (!minigameMatchFinish()) return;
|
if (!minigameMatchFinish()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
owner.setMiniGamePoints(visitor, 1, this.isOmok());
|
owner.setMiniGamePoints(visitor, 1, this.isOmok());
|
||||||
|
|
||||||
if (visitorforfeits < 4 || !forfeit) ownerscore += 50;
|
if (visitorforfeits < 4 || !forfeit) {
|
||||||
|
ownerscore += 50;
|
||||||
|
}
|
||||||
visitorscore += (15 * (forfeit ? -1 : 1));
|
visitorscore += (15 * (forfeit ? -1 : 1));
|
||||||
if (forfeit) visitorforfeits++;
|
if (forfeit) {
|
||||||
|
visitorforfeits++;
|
||||||
|
}
|
||||||
|
|
||||||
this.broadcast(PacketCreator.getMiniGameOwnerWin(this, forfeit));
|
this.broadcast(PacketCreator.getMiniGameOwnerWin(this, forfeit));
|
||||||
|
|
||||||
minigameMatchFinished();
|
minigameMatchFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void minigameMatchVisitorWins(boolean forfeit) {
|
public void minigameMatchVisitorWins(boolean forfeit) {
|
||||||
if (!minigameMatchFinish()) return;
|
if (!minigameMatchFinish()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
owner.setMiniGamePoints(visitor, 2, this.isOmok());
|
owner.setMiniGamePoints(visitor, 2, this.isOmok());
|
||||||
|
|
||||||
if (ownerforfeits < 4 || !forfeit) visitorscore += 50;
|
if (ownerforfeits < 4 || !forfeit) {
|
||||||
|
visitorscore += 50;
|
||||||
|
}
|
||||||
ownerscore += (15 * (forfeit ? -1 : 1));
|
ownerscore += (15 * (forfeit ? -1 : 1));
|
||||||
if (forfeit) ownerforfeits++;
|
if (forfeit) {
|
||||||
|
ownerforfeits++;
|
||||||
|
}
|
||||||
|
|
||||||
this.broadcast(PacketCreator.getMiniGameVisitorWin(this, forfeit));
|
this.broadcast(PacketCreator.getMiniGameVisitorWin(this, forfeit));
|
||||||
|
|
||||||
minigameMatchFinished();
|
minigameMatchFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void minigameMatchDraw() {
|
public void minigameMatchDraw() {
|
||||||
if (!minigameMatchFinish()) return;
|
if (!minigameMatchFinish()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
owner.setMiniGamePoints(visitor, 3, this.isOmok());
|
owner.setMiniGamePoints(visitor, 3, this.isOmok());
|
||||||
|
|
||||||
long timeNow = Server.getInstance().getCurrentTime();
|
long timeNow = Server.getInstance().getCurrentTime();
|
||||||
if (nextavailabletie <= timeNow) {
|
if (nextavailabletie <= timeNow) {
|
||||||
visitorscore += 10;
|
visitorscore += 10;
|
||||||
ownerscore += 10;
|
ownerscore += 10;
|
||||||
|
|
||||||
nextavailabletie = timeNow + 5 * 60 * 1000;
|
nextavailabletie = timeNow + 5 * 60 * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.broadcast(PacketCreator.getMiniGameTie(this));
|
this.broadcast(PacketCreator.getMiniGameTie(this));
|
||||||
|
|
||||||
minigameMatchFinished();
|
minigameMatchFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOwnerPoints() {
|
public void setOwnerPoints() {
|
||||||
ownerpoints++;
|
ownerpoints++;
|
||||||
if (ownerpoints + visitorpoints == matchestowin) {
|
if (ownerpoints + visitorpoints == matchestowin) {
|
||||||
@@ -346,7 +359,7 @@ public class MapleMiniGame extends AbstractMapObject {
|
|||||||
public MiniGameType getGameType() {
|
public MiniGameType getGameType() {
|
||||||
return GameType;
|
return GameType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOmok() {
|
public boolean isOmok() {
|
||||||
return GameType.equals(MiniGameType.OMOK);
|
return GameType.equals(MiniGameType.OMOK);
|
||||||
}
|
}
|
||||||
@@ -500,11 +513,11 @@ public class MapleMiniGame extends AbstractMapObject {
|
|||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOwnerScore() {
|
public int getOwnerScore() {
|
||||||
return ownerscore;
|
return ownerscore;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVisitorScore() {
|
public int getVisitorScore() {
|
||||||
return visitorscore;
|
return visitorscore;
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ import server.life.Monster;
|
|||||||
import server.life.NPC;
|
import server.life.NPC;
|
||||||
import server.life.PlayerNPC;
|
import server.life.PlayerNPC;
|
||||||
import server.maps.*;
|
import server.maps.*;
|
||||||
import server.maps.MapleMiniGame.MiniGameResult;
|
import server.maps.MiniGame.MiniGameResult;
|
||||||
import server.movement.LifeMovementFragment;
|
import server.movement.LifeMovementFragment;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -1962,7 +1962,7 @@ public class PacketCreator {
|
|||||||
addAnnounceBox(p, mps, 1);
|
addAnnounceBox(p, mps, 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MapleMiniGame miniGame = chr.getMiniGame();
|
MiniGame miniGame = chr.getMiniGame();
|
||||||
if (miniGame != null && miniGame.isOwner(chr)) {
|
if (miniGame != null && miniGame.isOwner(chr)) {
|
||||||
if (miniGame.hasFreeSlot()) {
|
if (miniGame.hasFreeSlot()) {
|
||||||
addAnnounceBox(p, miniGame, 1, 0);
|
addAnnounceBox(p, miniGame, 1, 0);
|
||||||
@@ -2145,7 +2145,7 @@ public class PacketCreator {
|
|||||||
p.writeByte(0);
|
p.writeByte(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addAnnounceBox(final OutPacket p, MapleMiniGame game, int ammount, int joinable) {
|
private static void addAnnounceBox(final OutPacket p, MiniGame game, int ammount, int joinable) {
|
||||||
p.writeByte(game.getGameType().getValue());
|
p.writeByte(game.getGameType().getValue());
|
||||||
p.writeInt(game.getObjectId()); // gameid/shopid
|
p.writeInt(game.getObjectId()); // gameid/shopid
|
||||||
p.writeString(game.getDescription()); // desc
|
p.writeString(game.getDescription()); // desc
|
||||||
@@ -4580,7 +4580,7 @@ public class PacketCreator {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet getMiniGame(Client c, MapleMiniGame minigame, boolean owner, int piece) {
|
public static Packet getMiniGame(Client c, MiniGame minigame, boolean owner, int piece) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
||||||
p.writeByte(PlayerInteractionHandler.Action.ROOM.getCode());
|
p.writeByte(PlayerInteractionHandler.Action.ROOM.getCode());
|
||||||
p.writeByte(1);
|
p.writeByte(1);
|
||||||
@@ -4618,39 +4618,39 @@ public class PacketCreator {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet getMiniGameReady(MapleMiniGame game) {
|
public static Packet getMiniGameReady(MiniGame game) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
||||||
p.writeByte(PlayerInteractionHandler.Action.READY.getCode());
|
p.writeByte(PlayerInteractionHandler.Action.READY.getCode());
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet getMiniGameUnReady(MapleMiniGame game) {
|
public static Packet getMiniGameUnReady(MiniGame game) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
||||||
p.writeByte(PlayerInteractionHandler.Action.UN_READY.getCode());
|
p.writeByte(PlayerInteractionHandler.Action.UN_READY.getCode());
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet getMiniGameStart(MapleMiniGame game, int loser) {
|
public static Packet getMiniGameStart(MiniGame game, int loser) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
||||||
p.writeByte(PlayerInteractionHandler.Action.START.getCode());
|
p.writeByte(PlayerInteractionHandler.Action.START.getCode());
|
||||||
p.writeByte(loser);
|
p.writeByte(loser);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet getMiniGameSkipOwner(MapleMiniGame game) {
|
public static Packet getMiniGameSkipOwner(MiniGame game) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
||||||
p.writeByte(PlayerInteractionHandler.Action.SKIP.getCode());
|
p.writeByte(PlayerInteractionHandler.Action.SKIP.getCode());
|
||||||
p.writeByte(0x01);
|
p.writeByte(0x01);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet getMiniGameRequestTie(MapleMiniGame game) {
|
public static Packet getMiniGameRequestTie(MiniGame game) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
||||||
p.writeByte(PlayerInteractionHandler.Action.REQUEST_TIE.getCode());
|
p.writeByte(PlayerInteractionHandler.Action.REQUEST_TIE.getCode());
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet getMiniGameDenyTie(MapleMiniGame game) {
|
public static Packet getMiniGameDenyTie(MiniGame game) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
||||||
p.writeByte(PlayerInteractionHandler.Action.ANSWER_TIE.getCode());
|
p.writeByte(PlayerInteractionHandler.Action.ANSWER_TIE.getCode());
|
||||||
return p;
|
return p;
|
||||||
@@ -4676,13 +4676,13 @@ public class PacketCreator {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet getMiniGameSkipVisitor(MapleMiniGame game) {
|
public static Packet getMiniGameSkipVisitor(MiniGame game) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
||||||
p.writeShort(PlayerInteractionHandler.Action.SKIP.getCode());
|
p.writeShort(PlayerInteractionHandler.Action.SKIP.getCode());
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet getMiniGameMoveOmok(MapleMiniGame game, int move1, int move2, int move3) {
|
public static Packet getMiniGameMoveOmok(MiniGame game, int move1, int move2, int move3) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
||||||
p.writeByte(PlayerInteractionHandler.Action.MOVE_OMOK.getCode());
|
p.writeByte(PlayerInteractionHandler.Action.MOVE_OMOK.getCode());
|
||||||
p.writeInt(move1);
|
p.writeInt(move1);
|
||||||
@@ -4691,7 +4691,7 @@ public class PacketCreator {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet getMiniGameNewVisitor(MapleMiniGame minigame, Character chr, int slot) {
|
public static Packet getMiniGameNewVisitor(MiniGame minigame, Character chr, int slot) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
||||||
p.writeByte(PlayerInteractionHandler.Action.VISIT.getCode());
|
p.writeByte(PlayerInteractionHandler.Action.VISIT.getCode());
|
||||||
p.writeByte(slot);
|
p.writeByte(slot);
|
||||||
@@ -4712,7 +4712,7 @@ public class PacketCreator {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Packet getMiniGameResult(MapleMiniGame game, int tie, int result, int forfeit) {
|
private static Packet getMiniGameResult(MiniGame game, int tie, int result, int forfeit) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
||||||
p.writeByte(PlayerInteractionHandler.Action.GET_RESULT.getCode());
|
p.writeByte(PlayerInteractionHandler.Action.GET_RESULT.getCode());
|
||||||
|
|
||||||
@@ -4759,15 +4759,15 @@ public class PacketCreator {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet getMiniGameOwnerWin(MapleMiniGame game, boolean forfeit) {
|
public static Packet getMiniGameOwnerWin(MiniGame game, boolean forfeit) {
|
||||||
return getMiniGameResult(game, 0, 1, forfeit ? 1 : 0);
|
return getMiniGameResult(game, 0, 1, forfeit ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet getMiniGameVisitorWin(MapleMiniGame game, boolean forfeit) {
|
public static Packet getMiniGameVisitorWin(MiniGame game, boolean forfeit) {
|
||||||
return getMiniGameResult(game, 0, 2, forfeit ? 1 : 0);
|
return getMiniGameResult(game, 0, 2, forfeit ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet getMiniGameTie(MapleMiniGame game) {
|
public static Packet getMiniGameTie(MiniGame game) {
|
||||||
return getMiniGameResult(game, 1, 3, 0);
|
return getMiniGameResult(game, 1, 3, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4779,7 +4779,7 @@ public class PacketCreator {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet getMatchCard(Client c, MapleMiniGame minigame, boolean owner, int piece) {
|
public static Packet getMatchCard(Client c, MiniGame minigame, boolean owner, int piece) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
||||||
p.writeByte(PlayerInteractionHandler.Action.ROOM.getCode());
|
p.writeByte(PlayerInteractionHandler.Action.ROOM.getCode());
|
||||||
p.writeByte(2);
|
p.writeByte(2);
|
||||||
@@ -4819,7 +4819,7 @@ public class PacketCreator {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet getMatchCardStart(MapleMiniGame game, int loser) {
|
public static Packet getMatchCardStart(MiniGame game, int loser) {
|
||||||
final OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
final OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
||||||
p.writeByte(PlayerInteractionHandler.Action.START.getCode());
|
p.writeByte(PlayerInteractionHandler.Action.START.getCode());
|
||||||
p.writeByte(loser);
|
p.writeByte(loser);
|
||||||
@@ -4840,7 +4840,7 @@ public class PacketCreator {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet getMatchCardNewVisitor(MapleMiniGame minigame, Character chr, int slot) {
|
public static Packet getMatchCardNewVisitor(MiniGame minigame, Character chr, int slot) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
||||||
p.writeByte(PlayerInteractionHandler.Action.VISIT.getCode());
|
p.writeByte(PlayerInteractionHandler.Action.VISIT.getCode());
|
||||||
p.writeByte(slot);
|
p.writeByte(slot);
|
||||||
@@ -4854,7 +4854,7 @@ public class PacketCreator {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet getMatchCardSelect(MapleMiniGame game, int turn, int slot, int firstslot, int type) {
|
public static Packet getMatchCardSelect(MiniGame game, int turn, int slot, int firstslot, int type) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
||||||
p.writeByte(PlayerInteractionHandler.Action.SELECT_CARD.getCode());
|
p.writeByte(PlayerInteractionHandler.Action.SELECT_CARD.getCode());
|
||||||
p.writeByte(turn);
|
p.writeByte(turn);
|
||||||
|
|||||||
Reference in New Issue
Block a user