diff --git a/checkstyle.txt b/checkstyle.txt index 263a0d1..04dcb57 100644 --- a/checkstyle.txt +++ b/checkstyle.txt @@ -69,7 +69,7 @@ Starting audit... [ERROR] /home/student/poo-tema1/./src/main/command/GetCardAtPosition.java:13:48: Parameter y should be final. [FinalParameters] [ERROR] /home/student/poo-tema1/./src/main/command/GetCardAtPosition.java:19:5: Class 'GetCardAtPosition' looks like designed for extension (can be subclassed), but the method 'execute' does not have javadoc that explains how to do that safely. If class is not designed for extension consider making the class 'GetCardAtPosition' final or making the method 'execute' static/final/abstract/empty, or adding allowed annotation for the method. [DesignForExtension] [ERROR] /home/student/poo-tema1/./src/main/command/GetCardAtPosition.java:20:25: Parameter output should be final. [FinalParameters] -[ERROR] /home/student/poo-tema1/./src/main/command/GetCardAtPosition.java:25: Line is longer than 100 characters (found 114). [LineLength] +[ERROR] /home/student/poo-tema1/./src/main/command/GetCardAtPosition.java:25: Line is longer than 100 characters (found 113). [LineLength] [ERROR] /home/student/poo-tema1/./src/main/command/UseEnvironmentCard.java:10:10: Variable 'game' must be private and have accessor methods. [VisibilityModifier] [ERROR] /home/student/poo-tema1/./src/main/command/UseEnvironmentCard.java:11:9: Variable 'handIdx' must be private and have accessor methods. [VisibilityModifier] [ERROR] /home/student/poo-tema1/./src/main/command/UseEnvironmentCard.java:12:9: Variable 'affectedRow' must be private and have accessor methods. [VisibilityModifier] diff --git a/input/test07_attack_card_invalid.json b/input/test07_attack_card_invalid.json index f7d0c71..ca283ea 100644 --- a/input/test07_attack_card_invalid.json +++ b/input/test07_attack_card_invalid.json @@ -391,6 +391,11 @@ "command": "placeCard", "handIdx": 0 }, + { + "command": "getCardAtPosition", + "x": 0, + "y": 3 + }, { "command": "useEnvironmentCard", "handIdx": 0, diff --git a/input/test14_use_hero_ability_2.json b/input/test13_use_hero_ability_2.json similarity index 100% rename from input/test14_use_hero_ability_2.json rename to input/test13_use_hero_ability_2.json diff --git a/input/test13_use_hero_ability_1_invalid.json b/input/test14_use_hero_ability_1_invalid.json similarity index 100% rename from input/test13_use_hero_ability_1_invalid.json rename to input/test14_use_hero_ability_1_invalid.json diff --git a/ref/ref_test04_use_environment_card.json b/ref/ref_test04_use_environment_card.json index 10bb061..018b060 100644 --- a/ref/ref_test04_use_environment_card.json +++ b/ref/ref_test04_use_environment_card.json @@ -16,6 +16,8 @@ }, { "command": "getCardAtPosition", + "x": 0, + "y": 0, "output": { "mana": 2, "attackDamage": 2, @@ -31,6 +33,8 @@ }, { "command": "getCardAtPosition", + "x": 3, + "y": 0, "output": { "mana": 1, "attackDamage": 1, @@ -50,6 +54,8 @@ }, { "command": "getCardAtPosition", + "x": 3, + "y": 0, "output": { "mana": 1, "attackDamage": 1, @@ -64,6 +70,8 @@ }, { "command": "getCardAtPosition", + "x": 0, + "y": 0, "output": { "mana": 2, "attackDamage": 2, diff --git a/ref/ref_test05_use_environment_card_invalid.json b/ref/ref_test05_use_environment_card_invalid.json index 39d56e2..a70f661 100644 --- a/ref/ref_test05_use_environment_card_invalid.json +++ b/ref/ref_test05_use_environment_card_invalid.json @@ -16,6 +16,8 @@ }, { "command": "getCardAtPosition", + "x": 1, + "y": 0, "output": { "mana": 3, "attackDamage": 2, @@ -30,6 +32,8 @@ }, { "command": "getCardAtPosition", + "x": 2, + "y": 0, "output": { "mana": 3, "attackDamage": 1, @@ -58,6 +62,8 @@ }, { "command": "getCardAtPosition", + "x": 2, + "y": 0, "output": { "mana": 3, "attackDamage": 1, @@ -73,6 +79,8 @@ }, { "command": "getCardAtPosition", + "x": 1, + "y": 0, "output": { "mana": 3, "attackDamage": 2, diff --git a/ref/ref_test07_attack_card_invalid.json b/ref/ref_test07_attack_card_invalid.json index f565697..b4ba293 100644 --- a/ref/ref_test07_attack_card_invalid.json +++ b/ref/ref_test07_attack_card_invalid.json @@ -1,4 +1,10 @@ [ + { + "command": "getCardAtPosition", + "x": 0, + "y": 3, + "output": "No card available at that position." + }, { "command": "cardUsesAttack", "cardAttacker": { @@ -13,6 +19,8 @@ }, { "command": "getCardAtPosition", + "x": 3, + "y": 0, "output": { "mana": 2, "attackDamage": 0, @@ -54,6 +62,8 @@ }, { "command": "getCardAtPosition", + "x": 0, + "y": 0, "output": { "mana": 3, "attackDamage": 0, diff --git a/ref/ref_test08_use_card_ability.json b/ref/ref_test08_use_card_ability.json index 0405e23..bf04afd 100644 --- a/ref/ref_test08_use_card_ability.json +++ b/ref/ref_test08_use_card_ability.json @@ -38,6 +38,8 @@ }, { "command": "getCardAtPosition", + "x": 3, + "y": 0, "output": { "mana": 2, "attackDamage": 0, @@ -89,6 +91,8 @@ }, { "command": "getCardAtPosition", + "x": 3, + "y": 0, "output": { "mana": 2, "attackDamage": 0, diff --git a/ref/ref_test09_use_card_ability_invalid.json b/ref/ref_test09_use_card_ability_invalid.json index 67c79ed..9b5b88f 100644 --- a/ref/ref_test09_use_card_ability_invalid.json +++ b/ref/ref_test09_use_card_ability_invalid.json @@ -1,6 +1,8 @@ [ { "command": "getCardAtPosition", + "x": 2, + "y": 0, "output": { "mana": 3, "attackDamage": 6, @@ -16,6 +18,8 @@ }, { "command": "getCardAtPosition", + "x": 2, + "y": 0, "output": { "mana": 3, "attackDamage": 6, diff --git a/ref/ref_test10_attack_hero.json b/ref/ref_test10_attack_hero.json index b2cc6ff..8723d62 100644 --- a/ref/ref_test10_attack_hero.json +++ b/ref/ref_test10_attack_hero.json @@ -38,6 +38,8 @@ }, { "command": "getCardAtPosition", + "x": 2, + "y": 0, "output": { "mana": 2, "attackDamage": 6, @@ -53,6 +55,8 @@ }, { "command": "getCardAtPosition", + "x": 3, + "y": 0, "output": { "mana": 2, "attackDamage": 6, @@ -135,6 +139,8 @@ }, { "command": "getCardAtPosition", + "x": 3, + "y": 1, "output": { "mana": 1, "attackDamage": 0, @@ -150,6 +156,8 @@ }, { "command": "getCardAtPosition", + "x": 2, + "y": 0, "output": { "mana": 2, "attackDamage": 6, diff --git a/ref/ref_test11_attack_hero_invalid.json b/ref/ref_test11_attack_hero_invalid.json index f30fb5b..9c2aad2 100644 --- a/ref/ref_test11_attack_hero_invalid.json +++ b/ref/ref_test11_attack_hero_invalid.json @@ -1,6 +1,8 @@ [ { "command": "getCardAtPosition", + "x": 2, + "y": 0, "output": { "mana": 1, "attackDamage": 5, @@ -77,6 +79,8 @@ }, { "command": "getCardAtPosition", + "x": 0, + "y": 0, "output": { "mana": 1, "attackDamage": 6, diff --git a/ref/ref_test12_use_hero_ability_1.json b/ref/ref_test12_use_hero_ability_1.json index e7ca6aa..5325618 100644 --- a/ref/ref_test12_use_hero_ability_1.json +++ b/ref/ref_test12_use_hero_ability_1.json @@ -1,6 +1,8 @@ [ { "command": "getCardAtPosition", + "x": 3, + "y": 0, "output": { "mana": 1, "attackDamage": 0, @@ -15,6 +17,8 @@ }, { "command": "getCardAtPosition", + "x": 1, + "y": 0, "output": { "mana": 1, "attackDamage": 6, diff --git a/ref/ref_test14_use_hero_ability_2.json b/ref/ref_test13_use_hero_ability_2.json similarity index 98% rename from ref/ref_test14_use_hero_ability_2.json rename to ref/ref_test13_use_hero_ability_2.json index 7f9d1d9..4fbee05 100644 --- a/ref/ref_test14_use_hero_ability_2.json +++ b/ref/ref_test13_use_hero_ability_2.json @@ -1,6 +1,8 @@ [ { "command": "getCardAtPosition", + "x": 0, + "y": 0, "output": { "mana": 1, "attackDamage": 6, @@ -16,6 +18,8 @@ }, { "command": "getCardAtPosition", + "x": 2, + "y": 0, "output": { "mana": 2, "attackDamage": 8, diff --git a/ref/ref_test13_use_hero_ability_1_invalid.json b/ref/ref_test14_use_hero_ability_1_invalid.json similarity index 98% rename from ref/ref_test13_use_hero_ability_1_invalid.json rename to ref/ref_test14_use_hero_ability_1_invalid.json index 8d20d94..39780c0 100644 --- a/ref/ref_test13_use_hero_ability_1_invalid.json +++ b/ref/ref_test14_use_hero_ability_1_invalid.json @@ -11,6 +11,8 @@ }, { "command": "getCardAtPosition", + "x": 0, + "y": 0, "output": { "mana": 3, "attackDamage": 0, @@ -25,6 +27,8 @@ }, { "command": "getCardAtPosition", + "x": 3, + "y": 0, "output": { "mana": 1, "attackDamage": 2, @@ -47,6 +51,8 @@ }, { "command": "getCardAtPosition", + "x": 3, + "y": 0, "output": { "mana": 1, "attackDamage": 2, @@ -61,6 +67,8 @@ }, { "command": "getCardAtPosition", + "x": 0, + "y": 0, "output": { "mana": 3, "attackDamage": 0, diff --git a/ref/ref_test15_use_hero_ability_2_invalid.json b/ref/ref_test15_use_hero_ability_2_invalid.json index eea3b88..909ff64 100644 --- a/ref/ref_test15_use_hero_ability_2_invalid.json +++ b/ref/ref_test15_use_hero_ability_2_invalid.json @@ -1,6 +1,8 @@ [ { "command": "getCardAtPosition", + "x": 1, + "y": 0, "output": { "mana": 3, "attackDamage": 6, @@ -15,6 +17,8 @@ }, { "command": "getCardAtPosition", + "x": 2, + "y": 0, "output": { "mana": 2, "attackDamage": 2, @@ -43,6 +47,8 @@ }, { "command": "getCardAtPosition", + "x": 2, + "y": 0, "output": { "mana": 2, "attackDamage": 2, @@ -58,6 +64,8 @@ }, { "command": "getCardAtPosition", + "x": 1, + "y": 0, "output": { "mana": 3, "attackDamage": 7, diff --git a/ref/ref_test16_multiple_games_valid.json b/ref/ref_test16_multiple_games_valid.json index 9967f16..feeced9 100644 --- a/ref/ref_test16_multiple_games_valid.json +++ b/ref/ref_test16_multiple_games_valid.json @@ -24,6 +24,8 @@ }, { "command": "getCardAtPosition", + "x": 0, + "y": 0, "output": { "mana": 2, "attackDamage": 5, @@ -91,6 +93,8 @@ }, { "command": "getCardAtPosition", + "x": 0, + "y": 0, "output": { "mana": 2, "attackDamage": 5, @@ -252,6 +256,8 @@ }, { "command": "getCardAtPosition", + "x": 2, + "y": 0, "output": { "mana": 1, "attackDamage": 7, @@ -287,6 +293,8 @@ }, { "command": "getCardAtPosition", + "x": 2, + "y": 0, "output": { "mana": 1, "attackDamage": 5, @@ -314,6 +322,8 @@ }, { "command": "getCardAtPosition", + "x": 0, + "y": 0, "output": { "mana": 2, "attackDamage": 0, @@ -332,6 +342,8 @@ }, { "command": "getCardAtPosition", + "x": 2, + "y": 0, "output": { "mana": 1, "attackDamage": 5, diff --git a/ref/ref_test17_multiple_games_invalid.json b/ref/ref_test17_multiple_games_invalid.json index 44998cd..6330470 100644 --- a/ref/ref_test17_multiple_games_invalid.json +++ b/ref/ref_test17_multiple_games_invalid.json @@ -1,6 +1,8 @@ [ { "command": "getCardAtPosition", + "x": 0, + "y": 0, "output": { "mana": 1, "attackDamage": 5, @@ -25,6 +27,8 @@ }, { "command": "getCardAtPosition", + "x": 2, + "y": 0, "output": { "mana": 1, "attackDamage": 6, @@ -72,6 +76,8 @@ }, { "command": "getCardAtPosition", + "x": 0, + "y": 0, "output": { "mana": 1, "attackDamage": 5, @@ -254,6 +260,8 @@ }, { "command": "getCardAtPosition", + "x": 1, + "y": 0, "output": { "mana": 1, "attackDamage": 5, @@ -297,6 +305,8 @@ }, { "command": "getCardAtPosition", + "x": 2, + "y": 0, "output": { "mana": 2, "attackDamage": 7, @@ -347,6 +357,8 @@ }, { "command": "getCardAtPosition", + "x": 2, + "y": 0, "output": { "mana": 2, "attackDamage": 7, @@ -390,6 +402,8 @@ }, { "command": "getCardAtPosition", + "x": 2, + "y": 0, "output": { "mana": 2, "attackDamage": 5, diff --git a/ref/ref_test18_big_game.json b/ref/ref_test18_big_game.json index b464f1b..856cc09 100644 --- a/ref/ref_test18_big_game.json +++ b/ref/ref_test18_big_game.json @@ -85,6 +85,8 @@ }, { "command": "getCardAtPosition", + "x": 2, + "y": 0, "output": { "mana": 4, "attackDamage": 5, @@ -124,6 +126,8 @@ }, { "command": "getCardAtPosition", + "x": 0, + "y": 0, "output": { "mana": 2, "attackDamage": 2, @@ -176,6 +180,8 @@ }, { "command": "getCardAtPosition", + "x": 0, + "y": 0, "output": { "mana": 2, "attackDamage": 2, @@ -202,6 +208,8 @@ }, { "command": "getCardAtPosition", + "x": 2, + "y": 0, "output": { "mana": 4, "attackDamage": 5, @@ -250,6 +258,8 @@ }, { "command": "getCardAtPosition", + "x": 0, + "y": 0, "output": { "mana": 2, "attackDamage": 2, diff --git a/src/main/command/GetCardAtPosition.java b/src/main/command/GetCardAtPosition.java index 2f045fb..b6aa83d 100644 --- a/src/main/command/GetCardAtPosition.java +++ b/src/main/command/GetCardAtPosition.java @@ -22,6 +22,8 @@ public void execute(ArrayNode output) { output.addObject() .put("command", "getCardAtPosition") - .putPOJO("output", (card != null) ? new MinionCard(card) : "No card available at that position."); + .putPOJO("output", (card != null) ? new MinionCard(card) : "No card available at that position.") + .put("x", x) + .put("y", y); } }