diff --git a/resources/teams/Apes/Gorilla.js b/resources/teams/Apes/Gorilla.js index b4f21cc..7b8a017 100644 --- a/resources/teams/Apes/Gorilla.js +++ b/resources/teams/Apes/Gorilla.js @@ -55,6 +55,7 @@ with(imports) { var Pitch = Java.type("gameLogic.Pitch"); playerToBeThrown.invokeSetPlayerCondition(PlayerCondition.DEAD); playerToBeThrown.invokeSetPosition(Pitch.THE_VOID); + player.sendMessageShowMe(player.toString(), "Oups, I just squeezed the poor blond capuchin to death."); var parameterArray = []; parameterArray[0] = FAILD_CLUMSY; player.getMatch().sendMessage(player.getMatch().getUser(userIndex), SBProtocolCommand.EVENT, parameterArray); @@ -83,6 +84,9 @@ with(imports) { if(willFailForSure){ var message = new SBProtocolMessage(player.getTeam().getCoach().getUID(), SBProtocolCommand.EVENT, " "); player.getRule(1).playerDown(message, player, YOU_SUCK); + if(player.getMatch().getPitch().getBallPos() == player.getPos()){ + player.getRule(4).scatterBallAround(userIndex); + } }else{ var enemyIndex = -1; if(userIndex == 0){ @@ -94,6 +98,14 @@ with(imports) { if(!(player.getRule(0).geTest(mod))){ var message = new SBProtocolMessage(player.getTeam().getCoach().getUID(), SBProtocolCommand.EVENT, " "); player.getRule(1).playerDown(message, player, YOU_SUCK); + if(player.getMatch().getPitch().getBallPos() == player.getPos()){ + player.getRule(4).scatterBallAround(userIndex); + } + } + if(!(player.getRule(0).geTest(mod))){ + if(player.getMatch().getPitch().getBallPos() == player.getPos()){ + player.getRule(4).scatterBallAround(userIndex); + } } } }else{ diff --git a/resources/teams/Apes/HowlerMonkey.js b/resources/teams/Apes/HowlerMonkey.js index f1a115a..bab133d 100644 --- a/resources/teams/Apes/HowlerMonkey.js +++ b/resources/teams/Apes/HowlerMonkey.js @@ -119,6 +119,7 @@ with(imports) { player.getRule(1).throwDice(message, defender); }else{ player.getRule(1).beatHim(defender, message, true); + player.getRule(2).apply(message, defender, defender.getPosition(), player.getTeam().getCoach().getUID(), player, defender.getPos()); } } else player.getRule(1).returnFailureMessage(message, SBProtocolMessage.FAILD_BLOCKING_NOT_POSSIBLE); } else player.getRule(1).returnFailureMessage(message, SBProtocolMessage.FAILD_PLAYER_CANNOT_TAKE_ACTION); diff --git a/resources/teams/PolarRegion/Seacow.js b/resources/teams/PolarRegion/Seacow.js index da479b7..bab133d 100644 --- a/resources/teams/PolarRegion/Seacow.js +++ b/resources/teams/PolarRegion/Seacow.js @@ -15,203 +15,154 @@ with(imports) { function setDescriptionLines(player, descriptionLines) { var lines = [ - "High chance of hurting enemies when blocking.", - "Can throw players with the attribute 'throwable',", - "but sometimes crushes them accidentally.", - "Heals faster than other players.", - "Stupid, so sometimes she just forgets", - "what she was about to do. This can be", - "helped by setting other players to her side." + "Cheater.", + "Cannot pick up the ball.", + "Whirls across the field with another monkey", + "blocking everyone in his path." ]; return Java.to(lines, Java.type("java.lang.String[]")); } - - var checkForStupidKey = "checkForStupid"; - var stupidKey = "isStupid"; - var stupidString = "HHNG"; + + var cheatedKey = "cheated"; + var noHandsString = "Sorry, but I have no hands left!"; + var ONLY_TORNADO = "SRY, BUT I'M SO HYPERACTIVE, THAT I CAN ONLY USE MY SPECIAL ABILITY TORNADO"; + var API_FIELD_FUNCTION_NAME = "apiField"; + var ENEMY_DOWN = "YOUR ENEMY IS "; var YOU_SUCK = "YOU ARE "; + var FAILD_PLAYER_IS_NOT_IN_A_GOOD_CONDITION = "PLAYER IS NOT IN A GOOD CONDITION"; var SBProtocolCommand = Java.type("network.SBProtocolCommand"); var SBProtocolMessage = Java.type("network.SBProtocolMessage"); - var ENEMY_DOWN = "YOUR ENEMY IS "; - var YOU_SUCK = "YOUR ARE "; - var FAILD_NO_THROWABLE_PLAYER_NEXT_TO_ME = "NO THROWABLE PLAYER NEXT TO ME"; - var FAILD_CLUMSY = "THE SEACOW WAS TOO CLUMSY, ROLLED ON THE TEAMMATE AND CRUMPLED HIM TO DEATH"; - var throwableKey = "throwable"; - var API_CHOICE_FUNCTION_NAME = "apiChoice"; - var API_AIM_FUNCTION_NAME = "apiAim"; - function apiChoice(player, teamIndex, playerToBeThrownIndex, userIndex){ - var playerToBeThrown = player.getTeam().getPlayers().get(playerToBeThrownIndex); - player.getMatch().setCurrentDefenderWaitingForAnswer(playerToBeThrown); - var playerIndex = player.findPlayerIndex(); - if(!(player.getMatch().d6.throwDie() == 1 && player.getMatch().d6.throwDie() == 1)){ - var parameterArray = []; - parameterArray[0] = SBProtocolMessage.EVENT_API_AIM; - parameterArray[1] = API_AIM_FUNCTION_NAME; - parameterArray[2] = playerIndex; - parameterArray[3] = 8; //MaxRange - player.getMatch().sendMessage(player.getMatch().getUser(userIndex), SBProtocolCommand.EVENT, parameterArray); + function apiField(player, x, y, userIndex){ + var directionThrow = player.getMatch().d3.throwDie(); + var newX = x; + var newY = y; + if(x == player.getPos().x){ + newX = directionThrow - 2 + x; + }else if(y == player.getPos().y){ + newY = directionThrow - 2 + y; + } + if(player.getMatch().getPitch().isOnField(newX, newY)){ + if(player.getMatch().getPitch().getFields()[newX][newY].getPlayer() == null){ + player.invokeSetPosition(newX, newY); + if(player.getMatch().getPitch().getBallPos().x == newX && player.getMatch().getPitch().getBallPos().y == newY){ + player.getRule(4).scatterBallAround(userIndex); + } + endMove(player); + }else{ + var message = new SBProtocolMessage(player.getTeam().getCoach().getUID(), SBProtocolCommand.EVENT, " "); + blockFromMove(player, message, player.getMatch().getPitch().getFields()[newX][newY].getPlayer()); + } }else{ - var PlayerCondition = Java.type("gameLogic.PlayerCondition"); - var Pitch = Java.type("gameLogic.Pitch"); - playerToBeThrown.invokeSetPlayerCondition(PlayerCondition.DEAD); - playerToBeThrown.invokeSetPosition(Pitch.THE_VOID); - var parameterArray = []; - parameterArray[0] = FAILD_CLUMSY; - player.getMatch().sendMessage(player.getMatch().getUser(userIndex), SBProtocolCommand.EVENT, parameterArray); + player.getRule(2).crowdBeatsUpPlayer(player); player.getMatch().setGamePhase(3); } - player.invokeSetRemainingBe(0); } - function apiAim(player, destX, destY, userIndex){ - var x = destX; - var y = destY; - for(var i = 0; i < 3; i++){ - scatterRoll = player.getMatch().scatter(); - x += scatterRoll.x; - y += scatterRoll.y; + function endMove(player){ + player.getMatch().setGamePhase(5); + player.invokeCountDownRemainingBe(1); + var PlayerCondition = Java.type("gameLogic.PlayerCondition"); + if(player.invokeGetRemainingBe() > 0 && player.invokeGetPlayerCondition() == PlayerCondition.FINE){ + var message = new SBProtocolMessage(player.getTeam().getCoach().getUID(), SBProtocolCommand.EVENT, " "); + player.getSpecialRule(0).apply(message); + }else{ + player.getMatch().setGamePhase(3); } - if(player.getMatch().getPitch().isOnField(x, y)){ - playerLanding(player.getMatch().getCurrentDefenderWaitingForAnswer(), userIndex, x, y, false); + } + function playerDownInAttack(message, p, s){ + armorRoll = p.getMatch().d6.throwDie() + p.getMatch().d6.throwDie(); + s = injuryRollInAttack(p, 0); + p.getRule(1).sendMessageShowMe(p.toString(), "I am " + s + "!"); + p.getRule(1).returnSuccessMessage(message, s); + var teamIndex = -1; + if(p.getTeam().equals(p.getMatch().getTeam(0))){ + teamIndex = 0; + }else if(p.getTeam().equals(p.getMatch().getTeam(1))){ + teamIndex = 1; }else{ - player.getRule(2).crowdBeatsUpPlayer(player.getMatch().getCurrentDefenderWaitingForAnswer()); + return; } - player.getMatch().setGamePhase(3); + p.getMatch().endTurn(teamIndex); } - function playerLanding(player, userIndex, x, y, willFailForSure){ - if(player.getMatch().getPitch().getFields()[x][y].getPlayer() == null){ - player.invokeSetPosition(x, y); - if(willFailForSure){ - var message = new SBProtocolMessage(player.getTeam().getCoach().getUID(), SBProtocolCommand.EVENT, " "); - player.getRule(1).playerDown(message, player, YOU_SUCK); - }else{ - var enemyIndex = -1; - if(userIndex == 0){ - enemyIndex = 1; - }else if(userIndex == 1){ - enemyIndex = 0; - } - var mod = -(player.getMatch().getTeam(enemyIndex).getTacklezones(x, y)); - if(!(player.getRule(0).geTest(mod))){ - var message = new SBProtocolMessage(player.getTeam().getCoach().getUID(), SBProtocolCommand.EVENT, " "); - player.getRule(1).playerDown(message, player, YOU_SUCK); - } - } + function injuryRollInAttack(player, modifier){ + s = ""; + injuryRoll = player.getMatch().d6.throwDie() + player.getMatch().d6.throwDie() + 1; + var PlayerCondition = Java.type("gameLogic.PlayerCondition"); + if(injuryRoll + modifier < 10){ + player.invokeSetPlayerCondition(PlayerCondition.KO); + s += "KO"; }else{ - var PlayerCondition = Java.type("gameLogic.PlayerCondition"); - var message = new SBProtocolMessage(player.getTeam().getCoach().getUID(), SBProtocolCommand.EVENT, " "); - playerCondition = player.getMatch().getPitch().getFields()[x][y].getPlayer().invokeGetPlayerCondition(); - defender = player.getMatch().getPitch().getFields()[x][y].getPlayer(); - player.getMatch().getPitch().getFields()[x][y].getPlayer().getRule(1).playerDown(message, player.getMatch().getPitch().getFields()[x][y].getPlayer(), ENEMY_DOWN); - if(playerCondition.equals(PlayerCondition.STUNNED) && defender.invokeGetPlayerCondition().equals(PlayerCondition.PRONE)){ - defender.invokeSetPlayerCondition(PlayerCondition.STUNNED); - } - var scatterRoll = player.getMatch().scatter(); - var newX = x + scatterRoll.x; - var newY = y + scatterRoll.y; - if(player.getMatch().getPitch().isOnField(newX, newY)){ - playerLanding(player, userIndex, newX, newY, true); + casultyRoll = player.getMatch().d6.throwDie() * 10 + player.getMatch().d8.throwDie(); + if(casultyRoll < 61){ + player.invokeSetPlayerCondition(PlayerCondition.INJURED); + s += "INJURED"; }else{ - player.getRule(2).crowdBeatsUpPlayer(player); + player.invokeSetPlayerCondition(PlayerCondition.DEAD); + s += "DEAD"; } + player.getMatch().addCasualty(player); } + player.invokeClearPosition(); + return s; } - - function checkForStupid(player){ - var difficulty = 4; - if(player.getTeam().getTacklezones(player.getPos()) > 0){ - difficulty = 2; - } - if(player.getSpecialStat(stupidKey) == "false"){ - if(player.getTeam().getMatch().d6.throwDie() < difficulty){ - player.setSpecialStat(stupidKey, "true"); - player.updateActiveTackleZone(); - } - } + function blockFromMove(player, message, defender){ + player.setSpecialStat(cheatedKey, "true"); + var PlayerCondition = Java.type("gameLogic.PlayerCondition"); + playerIsFine = (player.getMatch().getPitch().isOnField(player.getPos()) && player.invokeGetPlayerCondition() == PlayerCondition.FINE); + playerHasRemainingBe = (player.invokeGetRemainingBe() > 0); + playerWantsToBlitz = (player.invokeGetRemainingBe() != player.invokeGetBe()); + if(playerIsFine && playerHasRemainingBe){ + // Set fields for defender and message so they are available in attackerDown() and bothDown() + this.message = message; + if (player.getMatch().getPitch().isAdjacent(player.getPosition(), defender.getPosition())){ + if(defender.invokeGetPlayerCondition() == PlayerCondition.FINE){ + player.getRule(1).throwDice(message, defender); + }else{ + player.getRule(1).beatHim(defender, message, true); + player.getRule(2).apply(message, defender, defender.getPosition(), player.getTeam().getCoach().getUID(), player, defender.getPos()); + } + } else player.getRule(1).returnFailureMessage(message, SBProtocolMessage.FAILD_BLOCKING_NOT_POSSIBLE); + } else player.getRule(1).returnFailureMessage(message, SBProtocolMessage.FAILD_PLAYER_CANNOT_TAKE_ACTION); } - + function followWithoutQuestion(player, defenderField, message){ + player.invokeSetPosition(defenderField); + player.getRule(2).returnSuccessMessage(message, SBProtocolMessage.WORKD_FOLLOWED); + endMove(player); + } + function setPrice(player, price) { - return 110000; + return 70000; } function setGe(player, ge) { - return 1; + return 3; } function setRs(player, rs) { - return 9; + return 7; } function setSt(player, st) { - return 5; + return 7; } function setBe(player, be) { - return 4; + return 3; } function adjustMaxHeadcount(player, maxHeadcount) { return 1; } function setRules(player, ruleMove, ruleBlock, rulePush, ruleThrow, ruleCatch) { + player.addSpecialStat(cheatedKey, "false"); var rulesArray = [ruleMove, ruleBlock, rulePush, ruleThrow, ruleCatch]; - player.addSpecialStat(stupidKey, "false"); - - var RuleMove = Java.type("gameLogic.rules.RuleMove"); - var RuleMoveStupid = Java.extend(RuleMove); - var ruleMoveStupid = new RuleMoveStupid(rulesArray[0].getActor()){ - apply: function(message, path){ - var _super_ = Java.super(ruleMoveStupid); - var PlayerCondition = Java.type("gameLogic.PlayerCondition"); - var pathArray = Java.from(path); - if(pathArray.length < 2){ - if(player.invokeGetPlayerCondition() == PlayerCondition.FINE){ - return; - } - } - if(player.getTeam().getMovingPlayer() != player){ - player.invokeFunctionByName(checkForStupidKey, player); - } - if(player.getSpecialStat(stupidKey) == "true"){ - _super_.sendMessageShowMe(player.toString(), stupidString); - }else{ - _super_.apply(message, path); - } - } - }; - rulesArray[0] = ruleMoveStupid; - - var RuleBlock = Java.type("gameLogic.rules.RuleBlock"); - var RuleBlockStupidMightyBlowRegeneration = Java.extend(RuleBlock); - var ruleBlockStupidMightyBlowRegeneration = new RuleBlockStupidMightyBlowRegeneration(rulesArray[1].getActor()) { - apply: function(message, defender){ - var _super_ = Java.super(ruleBlockStupidMightyBlowRegeneration); - if(player.getTeam().getMovingPlayer() != player){ - player.invokeFunctionByName(checkForStupidKey, player); - } - if(player.getSpecialStat(stupidKey) == "true"){ - _super_.sendMessageShowMe(player.toString(), stupidString); - }else{ - _super_.apply(message, defender); - } - }, - defenderDown: function(message, defender) { - var PitchField = Java.type("gameLogic.PitchField"); - var defenderField = new PitchField(defender.getPos()); - defender.getRule(1).beingBlockedDefenderDown(message, player, defender, 1, 1); - return true; - }, - defenderStumbles: function(message, defender) { - var PitchField = Java.type("gameLogic.PitchField"); - var defenderField = new PitchField(defender.getPos()); - defender.getRule(1).beingBlockedDefenderStumbles(message, player, defender, 1, 1); - return true; - }, - bothDown: function(message, defender) { - var _super_ = Java.super(ruleBlockStupidMightyBlowRegeneration); - defender.getRule(1).beingBlockedBothDown(message, 1, 1); - _super_.playerDown(message, player, YOU_SUCK, 0, 0); - _super_.clearHighlightFields(); - return true; - }, - injuryRoll: function(modifier){ - s = ""; - injuryRoll = player.getMatch().d6.throwDie() + player.getMatch().d6.throwDie(); + + var RuleBlock = Java.type("gameLogic.rules.RuleBlock"); + var RuleBlockStuntyCheaterTornado = Java.extend(RuleBlock); + var ruleBlockStuntyCheaterTornado = new RuleBlockStuntyCheaterTornado(rulesArray[1].getActor()) { + apply: function(message, defender){ + var _super_ = Java.super(ruleBlockStuntyCheaterTornado); + _super_.sendMessageShowMe(player.getTeam().getCoach(), player.toString(), "I can only use my tornado!"); + _super_.returnFailureMessage(message, ONLY_TORNADO); + }, + injuryRoll: function(modifier){ + s = ""; + injuryRoll = player.getMatch().d6.throwDie() + player.getMatch().d6.throwDie() + 1; var PlayerCondition = Java.type("gameLogic.PlayerCondition"); if(injuryRoll + modifier < 8){ player.invokeSetPlayerCondition(PlayerCondition.STUNNED); @@ -231,70 +182,113 @@ with(imports) { } player.getMatch().addCasualty(player); } - if(player.getMatch().d6.throwDie() > 3){ - player.invokeSetPlayerCondition(PlayerCondition.FINE); - s += ", BUT REGENERATED"; - } player.invokeClearPosition(); } return s; - } - }; - rulesArray[1] = ruleBlockStupidMightyBlowRegeneration; - - var RuleThrow = Java.type("gameLogic.rules.RuleThrow"); - var RuleThrowStupid = Java.extend(RuleThrow); - var ruleThrowStupid = new RuleThrowStupid(rulesArray[3].getActor()){ - apply: function(message, destination){ - var _super_ = Java.super(ruleThrowStupid); - if(player.getTeam().getMovingPlayer() != player){ - player.invokeFunctionByName(checkForStupidKey, player); - } - if(player.getSpecialStat(stupidKey) == "true"){ - _super_.sendMessageShowMe(player.toString(), stupidString); - }else{ - _super_.apply(message, destination); - } - } - }; - rulesArray[3] = ruleThrowStupid; - - var RuleCatch = Java.type("gameLogic.rules.RuleCatch"); - var RuleCatchStupid = Java.extend(RuleCatch); - var ruleCatchStupid = new RuleCatchStupid(rulesArray[4].getActor()){ - apply: function(successfulThrow){ - var _super_ = Java.super(ruleCatchStupid); - if(player.getSpecialStat(stupidKey) == "true"){ - var actingUserIndex = -1; - if(player.getTeam() == player.getMatch().getTeam(0)){ - actingUserIndex = 0; - }else if(player.getTeam() == player.getMatch().getTeam(1)){ - actingUserIndex = 1; - }else{ - return; - } - _super_.scatterBallAround(actingUserIndex); - _super_.sendMessageShowMe(player.toString(), stupidString); - }else{ - _super_.apply(successfulThrow); - } - } - }; - rulesArray[4] = ruleCatchStupid; + }, + beatHim: function(defender, message, playerWantsToBlitz){ + var PlayerCondition = Java.type("gameLogic.PlayerCondition"); + defenderCondition = defender.invokeGetPlayerCondition(); + defenderPosition = defender.getPosition(); + defender.getRule(1).playerDown(message, defender, ENEMY_DOWN); + if(defenderCondition == PlayerCondition.STUNNED && defender.invokeGetPlayerCondition() == PlayerCondition.PRONE){ + defender.invokeSetPlayerCondition(PlayerCondition.STUNNED); + } + player.getRule(2).apply(message, defender, defenderPosition, player.getTeam().getCoach().getUID(), player, defenderPosition.getPos()); + }, + attackerDown: function(message) { + playerDownInAttack(message, player, YOU_SUCK); + player.getMatch().setGamePhase(3); + player.getMatch().clearCurrentHighlitedFields(); + var _super_ = Java.super(ruleBlockStuntyCheaterTornado); + _super_.clearHighlightFields(); + return true; + }, + bothDown: function(message, defender) { + defender.getRule(1).beingBlockedBothDown(message, 0, 0); + playerDownInAttack(message, player, YOU_SUCK); + player.getMatch().clearCurrentHighlitedFields(); + var _super_ = Java.super(ruleBlockStuntyCheaterTornado); + _super_.clearHighlightFields(); + player.getMatch().setGamePhase(3); + return true; + } + }; + rulesArray[1] = ruleBlockStuntyCheaterTornado; + + var RulePush = Java.type("gameLogic.rules.RulePush"); + var RulePushTornado = Java.extend(RulePush); + var rulePushTornado = new RulePushTornado(rulesArray[2].getActor()){ + backUp: function(defenderField, message, playerBackingUp){ + var _super_ = Java.super(rulePushTornado); + player.getRule(1).clearHighlightFields(); + followWithoutQuestion(player, defenderField, message); + } + }; + rulesArray[2] = rulePushTornado; + + var RuleMove = Java.type("gameLogic.rules.RuleMove"); + var RuleMoveNoHandsTornado = Java.extend(RuleMove); + var ruleMoveNoHandsTornado = new RuleMoveNoHandsTornado(rulesArray[0].getActor()){ + apply: function(message, path){ + var _super_ = Java.super(ruleMoveNoHandsTornado); + _super_.sendMessageShowMe(player.getTeam().getCoach(), player.toString(), "I can only use my tornado!"); + _super_.returnFailureMessage(message, ONLY_TORNADO); + }, + tryToPickUpBall: function(message, i, path){ + var _super_ = Java.super(ruleMoveNoHandsTornado); + return _super_.faildToPickUpBall(message); + } + }; + rulesArray[0] = ruleMoveNoHandsTornado; + + var RuleThrow = Java.type("gameLogic.rules.RuleThrow"); + var RuleThrowStuntyNoHands = Java.extend(RuleThrow); + var ruleThrowStuntyNoHands = new RuleThrowStuntyNoHands(rulesArray[3].getActor()){ + findThrowModificator: function(problems, distance){ + var _super_ = Java.super(ruleThrowStuntyNoHands); + _super_.findThrowModificator(problems - 1, distance); + }, + apply: function(message, destination){ + var _super_ = Java.super(ruleThrowStuntyNoHands); + _super_.sendMessageShowMe(player.getTeam().getCoach(), player.toString(), "I can only use my tornado!"); + _super_.sendMessage(message, SBProtocolCommand.EVENT, SBProtocolMessage.EVENT_SHOW_ME, player.toString(), noHandsString); + } + }; + rulesArray[3] = ruleThrowStuntyNoHands; + + var RuleCatch = Java.type("gameLogic.rules.RuleCatch"); + var RuleCatchNoHands = Java.extend(RuleCatch); + var ruleCatchNoHands = new RuleCatchNoHands(rulesArray[4].getActor()){ + apply: function(successfulThrow){ + var actingUserIndex; + if(player.getTeam() == player.getMatch().getTeam(0)){ + actingUserIndex = 0; + }else if(player.getTeam() == player.getMatch().getTeam(1)){ + actingUserIndex = 1; + }else{ + return; + } + var _super_ = Java.super(ruleCatchNoHands); + _super_.scatterBallAround(actingUserIndex); + }, + giveBall: function(message){ + var _super_ = Java.super(ruleCatchNoHands); + _super_.sendMessageShowMe(player.getTeam().getCoach(), player.toString(), noHandsString); + _super_.sendMessage(message, SBProtocolCommand.EVENT, noHandsString); + _super_.sendMessage(message, SBProtocolCommand.EVENT, SBProtocolMessage.EVENT_GIVE_THE_BALL_TO_SOMEONE); + } + }; + rulesArray[4] = ruleCatchNoHands; - var rulesToReturn = Java.to(rulesArray, Java.type("gameLogic.rules.Rule[]")); + var rulesToReturn = Java.to(rulesArray, Java.type("gameLogic.rules.Rule[]")); return rulesToReturn; } function eventHappened(player, eventString){ var SBProtocolMessage = Java.type("network.SBProtocolMessage"); - if(eventString == SBProtocolMessage.EVENT_YOUR_TURN || eventString == SBProtocolMessage.EVENT_ENDED_TURN){ - var difficulty = 3; - if(player.getTeam().getTacklezones(player.getPos()) > 0){ - difficulty = 1; - } - if(player.getTeam().getMatch().d6.throwDie() > difficulty){ - player.setSpecialStat(stupidKey, "false"); - player.updateActiveTackleZone(); + if(eventString == SBProtocolMessage.EVENT_SETUP_YOUR_TEAM){ + if(player.getSpecialStat(cheatedKey).equals("true")){ + player.invokeSetRedCard(true); } } } @@ -303,79 +297,49 @@ with(imports) { var SpecialRule = Java.type("gameLogic.rules.SpecialRule"); var specialRulesArray = []; - var SpecialRuleThrowTeammate = Java.extend(SpecialRule); - var specialRuleThrowTeammate = new SpecialRuleThrowTeammate(player, "Throw Teammate") { + var SpecialRuleTornado = Java.extend(SpecialRule); + var specialRuleTornado = new SpecialRuleTornado(player, "Tornado") { apply: function(message){ - var _super_ = Java.super(specialRuleThrowTeammate); + var _super_ = Java.super(specialRuleTornado); + _super_.checkForMovingPlayer(player); var PlayerCondition = Java.type("gameLogic.PlayerCondition"); - if(player.invokeGetRemainingBe() == 0 && !(player.getTeam().getMovingPlayer() == player)){ - _super_.returnFailureMessage(message, SBProtocolMessage.FAILD_YOU_ARE_EXHAUSTED); + if(player.invokeGetPlayerCondition() != PlayerCondition.FINE){ + _super_.returnFailureMessage(message, FAILD_PLAYER_IS_NOT_IN_A_GOOD_CONDITION); return; } - if(player.invokeGetPlayerCondition() != PlayerCondition.FINE){ - _super_.returnFailureMessage(message, SBProtocolMessage.FAILD_PLAYER_IS_NOT_IN_A_GOOD_CONDITION); - return; - } - _super_.checkForMovingPlayer(player); - if(player.getTeam().getMovingPlayer() != player){ - player.invokeFunctionByName(checkForStupidKey, player); - } - if(player.getSpecialStat(stupidKey) == "true"){ - _super_.sendMessageShowMe(player.toString(), stupidString); - }else{ - if(player.invokeGetRemainingBe() > 0){ - var parameterArray = []; - parameterArray[0] = SBProtocolMessage.EVENT_API_CHOICE; - parameterArray[1] = API_CHOICE_FUNCTION_NAME; - var playerCounter = 0; - var PitchField = Java.type("gameLogic.PitchField"); - var neighboursArray = Java.from(player.getMatch().getPitch().getNeighbours(player.getPos())); - for(var i = 0; i < neighboursArray.length; i++){ - var field = neighboursArray[i]; - if(field.getPlayer() != null){ - if(player.getTeam() == field.getPlayer().getTeam() && field.getPlayer().invokeGetPlayerCondition().equals(PlayerCondition.FINE)){ - var throwable = false; - throwable = field.getPlayer().getSpecialStat(throwableKey); - if(throwable == "true"){ - var teamIndex = -1; - if(player.getTeam() == field.getPlayer().getMatch().getTeam(0)){ - teamIndex = 0; - }else if(player.getTeam() == field.getPlayer().getMatch().getTeam(1)){ - teamIndex = 1; - } - parameterArray[2*playerCounter+2] = teamIndex; - parameterArray[2*playerCounter+3] = field.getPlayer().getId() - 1; - playerCounter++; - } - } - } - } - if(playerCounter > 0){ - player.getMatch().setGamePhase(5); - player.getMatch().setCurrentActorWaitingForAnswer(player); - _super_.sendMessage(message, SBProtocolCommand.EVENT, parameterArray); - }else{ - _super_.sendMessageShowMe(player.getTeam().getCoach(), player.toString(), "I can't find any throwable players"); - _super_.returnFailureMessage(message, FAILD_NO_THROWABLE_PLAYER_NEXT_TO_ME); - } - }else{ - _super_.returnFailureMessage(message, SBProtocolMessage.FAILD_YOU_ARE_EXHAUSTED); - } + if(player.invokeGetRemainingBe() > 0){ + var parameterArray = []; + parameterArray[0] = SBProtocolMessage.EVENT_API_FIELD; + parameterArray[1] = API_FIELD_FUNCTION_NAME; + var fieldCounter = 0; + for(var j = -1; j < 2; j++){ + for(var i = -1; i < 2; i++){ + var posX = player.getPos().x+i; + var posY = player.getPos().y+j; + if(player.getMatch().getPitch().isOnField(posX, posY)){ + if((i == 0 && j != 0) || (i != 0 && j == 0)){ + parameterArray[2*fieldCounter+2] = posX; + parameterArray[2*fieldCounter+3] = posY; + fieldCounter++; + } + } + } + } + player.getMatch().setGamePhase(5); + player.getMatch().setCurrentActorWaitingForAnswer(player); + _super_.sendMessage(message, SBProtocolCommand.EVENT, parameterArray); + }else{ + _super_.returnFailureMessage(message, SBProtocolMessage.FAILD_YOU_ARE_EXHAUSTED); } } }; - specialRulesArray[0] = specialRuleThrowTeammate; + specialRulesArray[0] = specialRuleTornado; var specialRulesToReturn = Java.to(specialRulesArray, Java.type("gameLogic.rules.SpecialRule[]")); return specialRulesToReturn; } function setTackleZone(player, tackleZone) {} - function setActiveTackleZone(player, activeTackleZone) { - var Vector = Java.type("java.util.Vector"); - if(player.getSpecialStat(stupidKey) == "true"){ - return new Vector(); - } - } + function setActiveTackleZone(player, activeTackleZone) {} function setPlayerCondition(player, playerCondition) {} function setPosition(player, position) {} function setIsHoldingBall(player, isHoldingBall) {} diff --git a/src/client/display/GameCanvas.java b/src/client/display/GameCanvas.java index 0e92b3f..5fb9d67 100644 --- a/src/client/display/GameCanvas.java +++ b/src/client/display/GameCanvas.java @@ -182,7 +182,7 @@ public void chooseTeam() { @Override public void paint(Graphics g) { Graphics2D g2D = (Graphics2D) g; - render(g2D); + if(getClient().getMatch() != null)render(g2D); } public void render(Graphics2D g) { diff --git a/src/client/logic/GameRenderer.java b/src/client/logic/GameRenderer.java index 3e7dbff..11c72d3 100644 --- a/src/client/logic/GameRenderer.java +++ b/src/client/logic/GameRenderer.java @@ -158,29 +158,12 @@ public void drawPlayersBench(Graphics2D g) { // set players on bench getGameCanvas().getPlayersOnBench().removeAllElements(); getGameCanvas().getPlayersOnOpponentBench().removeAllElements(); - try { - for (Player player : getClient().getMatch().getTeam(getGameCanvas().getClientIndex()).getPlayers()) - if (player.getPosition().equals(Pitch.THE_VOID)) // player is outside of field - getGameCanvas().addPlayerOnBench(player); - for (Player player : getClient().getMatch().getTeam(getGameCanvas().getClientIndex() == 0 ? 1 : 0).getPlayers()) - if (player.getPosition().equals(Pitch.THE_VOID)) // player is outside of field - getGameCanvas().addPlayerOnOpponentBench(player); - } catch(NullPointerException e) { // trap for strange nullpointer - getClient().log(Level.SEVERE, "Send the following information to milan!"); - if(getClient().getMatch() != null) { - if(getGameCanvas() != null) { - if(getClient().getMatch().getTeam(getGameCanvas().getClientIndex()) != null) { - if(getClient().getMatch().getTeam(getGameCanvas().getClientIndex()).getPlayers() != null) { - if(getClient().getMatch().getTeam(getGameCanvas().getClientIndex()).getPlayers().get(0) != null) { - if(getClient().getMatch().getTeam(getGameCanvas().getClientIndex()).getPlayers().get(0).getPosition() != null) { - getClient().log(Level.SEVERE, "strange"); - } else getClient().log(Level.SEVERE, "position of player at 0 is null"); - } else getClient().log(Level.SEVERE, "player at 0 is null"); - } else getClient().log(Level.SEVERE, "players are null"); - } else getClient().log(Level.SEVERE, "team is null"); - } else getClient().log(Level.SEVERE, "game canvas is null"); - } else getClient().log(Level.SEVERE, "match is null"); - } + for (Player player : getClient().getMatch().getTeam(getGameCanvas().getClientIndex()).getPlayers()) + if (player.getPosition().equals(Pitch.THE_VOID)) // player is outside of field + getGameCanvas().addPlayerOnBench(player); + for (Player player : getClient().getMatch().getTeam(getGameCanvas().getClientIndex() == 0 ? 1 : 0).getPlayers()) + if (player.getPosition().equals(Pitch.THE_VOID)) // player is outside of field + getGameCanvas().addPlayerOnOpponentBench(player); // draw players on own bench for (int i = 1; i <= getGameCanvas().getPlayersOnBench().size(); i++) { diff --git a/src/gameLogic/Player.java b/src/gameLogic/Player.java index 87eaf13..5cc9bf4 100644 --- a/src/gameLogic/Player.java +++ b/src/gameLogic/Player.java @@ -7,6 +7,7 @@ import javax.vecmath.*; +import server.logic.User; import gameLogic.rules.*; /** @@ -393,6 +394,14 @@ public int findPlayerIndex(){ } return -1; } + + public void sendMessageShowMe(User user, String a, String b){ + rules[0].sendMessageShowMe(user, a, b); + } + + public void sendMessageShowMe(String a, String b){ + rules[0].sendMessageShowMe(a, b); + } // DIRECT GETTERS FOR GUI diff --git a/src/gameLogic/Team.java b/src/gameLogic/Team.java index 865b7f8..7a8dd88 100644 --- a/src/gameLogic/Team.java +++ b/src/gameLogic/Team.java @@ -193,7 +193,14 @@ public static String coolTeamName(){ "Hippie Flowers", "Hanging Trees", "Chocolate flips", - "Mourning Monkeys"}; + "Mourning Monkeys", + "Running Clocks", + "Tea Sippers", + "Curly Ponies", + "Greedy Bookworms", + "Exam Crashers", + "Fancy Pencils", + "Russian Mafia"}; return names[(int)(Math.random()*names.length)]; } diff --git a/src/gameLogic/dice/EightSidedDie.java b/src/gameLogic/dice/EightSidedDie.java index 63d9b30..020e708 100644 --- a/src/gameLogic/dice/EightSidedDie.java +++ b/src/gameLogic/dice/EightSidedDie.java @@ -1,23 +1,13 @@ package gameLogic.dice; /** - * A die with eight sides + * Created by matias on 24.3.15. */ public class EightSidedDie implements Die { - private int throwCounter = 0; /** * @return returns a int from 1 to 8 */ public int throwDie(){ - /*int[] throwsForPresentation = {3, 3, 6}; - if(throwCounter < throwsForPresentation.length){ - int i = throwsForPresentation[throwCounter]; - throwCounter++; - System.out.println("D8: " + i); - return i; - }*/ - int i = rand.nextInt(8) + 1; -// System.out.println("D8: " + i); - return i; + return rand.nextInt(8) + 1; } } diff --git a/src/gameLogic/dice/SixSidedDie.java b/src/gameLogic/dice/SixSidedDie.java index cb0c14d..1f69b43 100644 --- a/src/gameLogic/dice/SixSidedDie.java +++ b/src/gameLogic/dice/SixSidedDie.java @@ -1,24 +1,14 @@ package gameLogic.dice; /** - * A die with six sides + * Created by milan on 23.3.15. */ public class SixSidedDie implements Die { - int throwCounter = 0; /** * @return returns a int from 1 to 6 */ public int throwDie(){ - /*int[] throwsForPresentation = {5,5,4,4,5,2,2,5,6,2,6,1,1,4,3,2,4,2,2,2,3,5,4,1,3,6,1,2,2,3,1,1,5,4,2,2,4,5,4,6,2,1,3,4,3,5,2,1,3, 3, 3, 5, 1, 2, 3, 6, 4, 5, 6, 6, 6, 1, 4, 6, 1, 1, 2, 1, 2, 3, 4, 5, 1, 1, 5, 1, 2, 4, }; - if(throwCounter < throwsForPresentation.length){ - int i = throwsForPresentation[throwCounter]; - throwCounter++; - System.out.println("D6: " + i); - return i; - }*/ - int i = rand.nextInt(6) + 1; -// System.out.println("D6: " + i); - return i; + return rand.nextInt(6) + 1; } } diff --git a/src/network/SBSocket.java b/src/network/SBSocket.java index e7e49cd..83fcd0b 100644 --- a/src/network/SBSocket.java +++ b/src/network/SBSocket.java @@ -115,7 +115,7 @@ public void createListenerAndWriter() throws SBNetworkException { */ public void sendMessage(SBProtocolMessage message) { if (message != null) { - // add to unanswered messages only if the message is no answer to another message and no ping + // add to unanswered messages only if the message is no answer to another message and no ping if (message.getModule() != SBProtocolCommand.SBProtocolModule.SUC && message.getModule() != SBProtocolCommand.SBProtocolModule.FAI && message.getModule() != SBProtocolCommand.SBProtocolModule.PNG) diff --git a/src/server/logic/ServerMatch.java b/src/server/logic/ServerMatch.java index da94e05..75f78f0 100644 --- a/src/server/logic/ServerMatch.java +++ b/src/server/logic/ServerMatch.java @@ -844,6 +844,7 @@ private boolean giveBall(SBProtocolMessage message){ } try{ getPitch().adjustBallPos(new Vector2d(-1, -1)); + sendBallPos(); return ((RuleCatch)getTeam(actingUserIndex).getPlayers().get(playerIndex).getRule(4)).giveBall(message); }catch(IndexOutOfBoundsException e){ returnFailureMessage(message, SBProtocolMessage.FAILD_PLAYER_DOESNT_EXIST);