Skip to content

Commit 16fbce4

Browse files
feat: aerial attackers (#4)
* feat: CPP and Python Aerial Attacker Attribute * feat: java is_aerial type attribute --------- Co-authored-by: Ashwani <[email protected]>
1 parent e0f8633 commit 16fbce4

File tree

6 files changed

+20
-16
lines changed

6 files changed

+20
-16
lines changed

cpp/main.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ void init_constants() {
99

1010
std::unordered_map<size_t, Attributes> attacker_type_to_attributes;
1111
for (size_t i = 1; i <= Constants::NO_OF_ATTACKER_TYPES; i++) {
12-
unsigned hp, range, attack_power, speed, price;
13-
std::cin >> hp >> range >> attack_power >> speed >> price;
12+
unsigned hp, range, attack_power, speed, price, is_aerial;
13+
std::cin >> hp >> range >> attack_power >> speed >> price >> is_aerial;
1414
attacker_type_to_attributes.insert(
15-
std::make_pair(i, Attributes(hp, range, attack_power, speed, price)));
15+
std::make_pair(i, Attributes(hp, range, attack_power, speed, price, is_aerial)));
1616
}
1717
Constants::ATTACKER_TYPE_ATTRIBUTES = attacker_type_to_attributes;
1818

@@ -21,10 +21,10 @@ void init_constants() {
2121

2222
std::unordered_map<size_t, Attributes> defender_type_to_attributes;
2323
for (size_t i = 1; i <= Constants::NO_OF_DEFENDER_TYPES; i++) {
24-
unsigned hp, range, attack_power, speed, price;
25-
std::cin >> hp >> range >> attack_power >> speed >> price;
24+
unsigned hp, range, attack_power, speed, price, is_aerial;
25+
std::cin >> hp >> range >> attack_power >> speed >> price >> is_aerial;
2626
defender_type_to_attributes.insert(
27-
std::make_pair(i, Attributes(hp, range, attack_power, speed, price)));
27+
std::make_pair(i, Attributes(hp, range, attack_power, speed, price, is_aerial)));
2828
}
2929
Constants::DEFENDER_TYPE_ATTRIBUTES = defender_type_to_attributes;
3030
}

cpp/player_code.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
#include <vector>
1111

1212
Attributes::Attributes(unsigned hp, unsigned range, unsigned attack_power,
13-
unsigned speed, unsigned price)
13+
unsigned speed, unsigned price, unsigned is_aerial)
1414
: hp(hp), range(range), attack_power(attack_power), speed(speed),
15-
price(price) {}
15+
price(price), is_aerial(is_aerial) {}
1616

1717
Position::Position(int x, int y) : _x(x), _y(y) {}
1818

cpp/player_code.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ struct Attributes {
1313
const unsigned attack_power;
1414
const unsigned speed;
1515
const unsigned price;
16+
const unsigned is_aerial;
1617
Attributes(unsigned hp, unsigned range, unsigned attack_power, unsigned speed,
17-
unsigned price);
18+
unsigned price, unsigned is_aerial);
1819
};
1920

2021
struct Constants {

java/Attributes.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ public class Attributes {
44
public final int attackPower;
55
public final int speed;
66
public final int price;
7+
public final int is_aerial;
78

8-
public Attributes(int hp, int range, int attackPower, int speed, int price) {
9+
public Attributes(int hp, int range, int attackPower, int speed, int price, int is_aerial) {
910
this.hp = hp;
1011
this.range = range;
1112
this.attackPower = attackPower;
1213
this.speed = speed;
1314
this.price = price;
15+
this.is_aerial = is_aerial;
1416
}
1517
}

java/Main.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ public static void main(String[] args) {
7474
Constants.ATTACKER_TYPE_ATTRIBUTES = new HashMap<Integer, Attributes>();
7575
for (int i = 1; i <= Constants.NO_OF_ATTACKER_TYPES; i++) {
7676
Constants.ATTACKER_TYPE_ATTRIBUTES.put(i,
77-
new Attributes(in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt()));
77+
new Attributes(in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt()));
7878
}
7979

8080
Constants.NO_OF_DEFENDER_TYPES = in.nextInt();
8181
Constants.DEFENDER_TYPE_ATTRIBUTES = new HashMap<Integer, Attributes>();
8282
for (int i = 1; i <= Constants.NO_OF_DEFENDER_TYPES; i++) {
8383
Constants.DEFENDER_TYPE_ATTRIBUTES.put(i,
84-
new Attributes(in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt()));
84+
new Attributes(in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt()));
8585
}
8686

8787
GameMap map = getInitialMap();

python/player_code.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class ActorType:
1717
range: int
1818
attack_power: int
1919
price: int
20+
is_aerial: int
2021

2122

2223
@dataclass(frozen=True)
@@ -98,17 +99,17 @@ def initialize(cls):
9899
cls.NO_OF_ATTACKER_TYPES = int(input())
99100
cls.ATTACKER_TYPE_ATTRIBUTES = {}
100101
for i in range(1, cls.NO_OF_ATTACKER_TYPES + 1):
101-
hp, a_range, attack_power, speed, price = map(int, input().split())
102+
hp, a_range, attack_power, speed, price, is_aerial = map(int, input().split())
102103
cls.ATTACKER_TYPE_ATTRIBUTES[i] = AttackerType(
103-
hp, a_range, attack_power, price, speed
104+
hp, a_range, attack_power, price, is_aerial, speed
104105
)
105106

106107
cls.NO_OF_DEFENDER_TYPES = int(input())
107108
cls.DEFENDER_TYPE_ATTRIBUTES = {}
108109
for i in range(1, cls.NO_OF_DEFENDER_TYPES + 1):
109-
hp, d_range, attack_power, _, price = map(int, input().split())
110+
hp, d_range, attack_power, _, price, is_aerial = map(int, input().split())
110111
cls.DEFENDER_TYPE_ATTRIBUTES[i] = DefenderType(
111-
hp, d_range, attack_power, price
112+
hp, d_range, attack_power, price, is_aerial
112113
)
113114

114115

0 commit comments

Comments
 (0)