From 34a7f2bb117e7f81be7a7ec5d38ebbc7a5e2cf44 Mon Sep 17 00:00:00 2001 From: Vignesh Duraisamy Date: Thu, 16 Feb 2023 01:09:46 +0530 Subject: [PATCH 1/2] feat: CPP and Python Aerial Attacker Attribute --- cpp/main.cpp | 12 ++++++------ cpp/player_code.cpp | 4 ++-- cpp/player_code.h | 3 ++- python/player_code.py | 9 +++++---- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/cpp/main.cpp b/cpp/main.cpp index 0a26a61..a93e4e8 100644 --- a/cpp/main.cpp +++ b/cpp/main.cpp @@ -9,10 +9,10 @@ void init_constants() { std::unordered_map attacker_type_to_attributes; for (size_t i = 1; i <= Constants::NO_OF_ATTACKER_TYPES; i++) { - unsigned hp, range, attack_power, speed, price; - std::cin >> hp >> range >> attack_power >> speed >> price; + unsigned hp, range, attack_power, speed, price, is_aerial; + std::cin >> hp >> range >> attack_power >> speed >> price >> is_aerial; attacker_type_to_attributes.insert( - std::make_pair(i, Attributes(hp, range, attack_power, speed, price))); + std::make_pair(i, Attributes(hp, range, attack_power, speed, price, is_aerial))); } Constants::ATTACKER_TYPE_ATTRIBUTES = attacker_type_to_attributes; @@ -21,10 +21,10 @@ void init_constants() { std::unordered_map defender_type_to_attributes; for (size_t i = 1; i <= Constants::NO_OF_DEFENDER_TYPES; i++) { - unsigned hp, range, attack_power, speed, price; - std::cin >> hp >> range >> attack_power >> speed >> price; + unsigned hp, range, attack_power, speed, price, is_aerial; + std::cin >> hp >> range >> attack_power >> speed >> price >> is_aerial; defender_type_to_attributes.insert( - std::make_pair(i, Attributes(hp, range, attack_power, speed, price))); + std::make_pair(i, Attributes(hp, range, attack_power, speed, price, is_aerial))); } Constants::DEFENDER_TYPE_ATTRIBUTES = defender_type_to_attributes; } diff --git a/cpp/player_code.cpp b/cpp/player_code.cpp index 0ebfc4f..b091f9d 100644 --- a/cpp/player_code.cpp +++ b/cpp/player_code.cpp @@ -10,9 +10,9 @@ #include Attributes::Attributes(unsigned hp, unsigned range, unsigned attack_power, - unsigned speed, unsigned price) + unsigned speed, unsigned price, unsigned is_aerial) : hp(hp), range(range), attack_power(attack_power), speed(speed), - price(price) {} + price(price), is_aerial(is_aerial) {} Position::Position(int x, int y) : _x(x), _y(y) {} diff --git a/cpp/player_code.h b/cpp/player_code.h index 91e9c44..61dbd7a 100644 --- a/cpp/player_code.h +++ b/cpp/player_code.h @@ -13,8 +13,9 @@ struct Attributes { const unsigned attack_power; const unsigned speed; const unsigned price; + const unsigned is_aerial; Attributes(unsigned hp, unsigned range, unsigned attack_power, unsigned speed, - unsigned price); + unsigned price, unsigned is_aerial); }; struct Constants { diff --git a/python/player_code.py b/python/player_code.py index 4a8a487..bd06341 100644 --- a/python/player_code.py +++ b/python/player_code.py @@ -17,6 +17,7 @@ class ActorType: range: int attack_power: int price: int + is_aerial: int @dataclass(frozen=True) @@ -98,17 +99,17 @@ def initialize(cls): cls.NO_OF_ATTACKER_TYPES = int(input()) cls.ATTACKER_TYPE_ATTRIBUTES = {} for i in range(1, cls.NO_OF_ATTACKER_TYPES + 1): - hp, a_range, attack_power, speed, price = map(int, input().split()) + hp, a_range, attack_power, speed, price, is_aerial = map(int, input().split()) cls.ATTACKER_TYPE_ATTRIBUTES[i] = AttackerType( - hp, a_range, attack_power, price, speed + hp, a_range, attack_power, price, is_aerial, speed ) cls.NO_OF_DEFENDER_TYPES = int(input()) cls.DEFENDER_TYPE_ATTRIBUTES = {} for i in range(1, cls.NO_OF_DEFENDER_TYPES + 1): - hp, d_range, attack_power, _, price = map(int, input().split()) + hp, d_range, attack_power, _, price, is_aerial = map(int, input().split()) cls.DEFENDER_TYPE_ATTRIBUTES[i] = DefenderType( - hp, d_range, attack_power, price + hp, d_range, attack_power, price, is_aerial ) From 67136c5c0d425c3e53e438208770cad50d4a7f90 Mon Sep 17 00:00:00 2001 From: Ashwani Date: Sat, 18 Feb 2023 15:35:00 +0530 Subject: [PATCH 2/2] feat: java is_aerial type attribute --- java/Attributes.java | 4 +++- java/Main.java | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/java/Attributes.java b/java/Attributes.java index e83b17f..37bc3e1 100644 --- a/java/Attributes.java +++ b/java/Attributes.java @@ -4,12 +4,14 @@ public class Attributes { public final int attackPower; public final int speed; public final int price; + public final int is_aerial; - public Attributes(int hp, int range, int attackPower, int speed, int price) { + public Attributes(int hp, int range, int attackPower, int speed, int price, int is_aerial) { this.hp = hp; this.range = range; this.attackPower = attackPower; this.speed = speed; this.price = price; + this.is_aerial = is_aerial; } } diff --git a/java/Main.java b/java/Main.java index 82c1a3a..df9d162 100644 --- a/java/Main.java +++ b/java/Main.java @@ -74,14 +74,14 @@ public static void main(String[] args) { Constants.ATTACKER_TYPE_ATTRIBUTES = new HashMap(); for (int i = 1; i <= Constants.NO_OF_ATTACKER_TYPES; i++) { Constants.ATTACKER_TYPE_ATTRIBUTES.put(i, - new Attributes(in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt())); + new Attributes(in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt())); } Constants.NO_OF_DEFENDER_TYPES = in.nextInt(); Constants.DEFENDER_TYPE_ATTRIBUTES = new HashMap(); for (int i = 1; i <= Constants.NO_OF_DEFENDER_TYPES; i++) { Constants.DEFENDER_TYPE_ATTRIBUTES.put(i, - new Attributes(in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt())); + new Attributes(in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt())); } GameMap map = getInitialMap();