Commit d20796c2 authored by nschroeder1771's avatar nschroeder1771
Browse files

Added a Wall Ant type that must be placed next to another ant to survive(not ...

Added a Wall Ant type that must be placed next to another ant to survive(not  fully functional yet). Also added the setup for the first doctest.
parent a080cf54
......@@ -115,6 +115,7 @@ class UnitType(Enum):
THROWER = 'THROWER'
SUPER_HARVESTER = 'SUPER HARVESTER'
NINJA_THROWER = 'NINJA THROWER'
WALL_ANT = 'WALL ANT'
class Insect(object):
......@@ -300,7 +301,11 @@ class SuperHarvester(Harvester):
"""
super().act(game_state)
# def death(self):
def death(self):
"""
In order for a super harvester to live it must have a leaf thrower next to it.
"""
class Thrower(Ant):
......@@ -430,7 +435,19 @@ class Thrower(Ant):
"""
If there is a Bee approaching this Ant, and it is in-range, consume one unit of ammo to throw a leaf at that bee
and reduce its health:
>>> # Placeholder
>>> place = ColonyPlace(1, 0)
>>> next_place = ColonyPlace(0, 0)
>>> place.connect_to(next_place)
>>> state = GameState(places=[place, next_place], queen_place=None, ant_archetypes=[], food=0)
>>> ant = Thrower(unit_type=None, food_cost=0, health=5, damage=1, ammo= 4, minimum_range=0, maximum_range=2)
>>> place.add_insect(ant)
>>> bee = Bee(health=1, damage=1, delay=0)
>>> place.add_insect(bee)
>>> bee.act(state)
>>> bee.health
0
>>> ant.ammo
3
But ignore any Bee that is out of range:
>>> # Placeholder
......@@ -459,7 +476,7 @@ class NinjaThrower(Thrower):
def __init__(self, unit_type, food_cost, health, damage, ammo, minimum_range=0, maximum_range=0):
"""
Create a Thrower with the given type, cost, health, and damage.
Create a Ninja Thrower with the given type, cost, health, and damage.
A Thrower can only target bees at distances between its minimum range and maximum range, inclusive. A range of
0 corresponds to the Place the Ant is in, a range of 1 corresponds to all places leading to there, etc.
......@@ -468,6 +485,36 @@ class NinjaThrower(Thrower):
"""
super().__init__(unit_type, food_cost, health, damage, ammo, minimum_range, maximum_range)
def act(self, game_state):
"""
If there is a Bee approaching this Ant, and it is in-range, consume one unit of ammo to throw a leaf at that bee
and reduce its health:
"""
target_bee = self._target_bee
if target_bee is not None:
self._hit_bee(target_bee)
self.ammo -= 1
if self.ammo <= 0:
self.reduce_health(self.health)
if target_bee is None:
self.ammo += 1
class WallAnt(Ant):
"""
A Wall Ant is a ant that has lots of health and must be next to another ant to live.
"""
def __init__(self, unit_type, food_cost, health):
"""
Creates a Wall Ant with the given type, food cost, and health.
"""
super().__init__(unit_type, food_cost, health)
def death(self):
"""
The wall ant must be next to another ant in order to survive.
"""
class GameOutcome(Enum):
"""
......@@ -576,7 +623,9 @@ STANDARD_ANT_ARCHETYPES = (
Harvester(UnitType.HARVESTER, food_cost=3, health=1, production=1),
Thrower(UnitType.THROWER, food_cost=7, health=1, damage=1, ammo=4, minimum_range=0, maximum_range=2),
SuperHarvester(UnitType.SUPER_HARVESTER, food_cost=5, health=1, production=2),
NinjaThrower(UnitType.NINJA_THROWER, food_cost=10, health=1, damage=4, ammo=4, minimum_range=0, maximum_range=2)
NinjaThrower(UnitType.NINJA_THROWER, food_cost=10, health=1, damage=2, ammo=4, minimum_range=0, maximum_range=2),
WallAnt(UnitType.WALL_ANT, food_cost=5, health= 3)
)
......
......@@ -114,6 +114,7 @@ class Game(BoxLayout):
ants_vs_some_bees.UnitType.THROWER: 'assets/ant_medium.gif',
ants_vs_some_bees.UnitType.SUPER_HARVESTER: 'assets/ant_fire.gif',
ants_vs_some_bees.UnitType.NINJA_THROWER: 'assets/ant_ninja.gif',
ants_vs_some_bees.UnitType.WALL_ANT: 'assets/ant_wall.gif'
}
LEAF_SPRITE_FILENAMES = {
ants_vs_some_bees.UnitType.THROWER: 'assets/leaf_green.gif',
......
#:import Game main.Game
#:import UnitType ants_vs_some_bees.UnitType
#:set SPRITE_SIZE (Game.SPRITE_WIDTH, Game.SPRITE_HEIGHT)
#:set UNIT_NAMES {UnitType.HARVESTER: 'Harvester Ant', UnitType.THROWER: 'Leaf Thrower', UnitType.SUPER_HARVESTER: 'Super Harvester Ant', UnitType.NINJA_THROWER: 'Ninja Thrower'}
#:set UNIT_NAMES {UnitType.HARVESTER: 'Harvester Ant', UnitType.THROWER: 'Leaf Thrower', UnitType.SUPER_HARVESTER: 'Super Harvester Ant', UnitType.NINJA_THROWER: 'Ninja Thrower', UnitType.WALL_ANT: 'Wall Ant'}
ScreenManager:
Screen:
......@@ -100,10 +100,13 @@ ScreenManager:
text: 'An leaf thrower costs 7 food units to deploy and dies after throwing four leaves. It will only throw leaves outward, away from the queen.'
CaptionedSprite:
source: 'assets/ant_fire.gif'
text: 'A super harvester ant costs 5 food units to deploy, but produces 2 units of food per turn.'
text: 'A super harvester ant costs 5 food units to deploy, but produces 2 units of food per turn. This ant also must be next to a leaf thrower in order to survive'
CaptionedSprite:
source: 'assets/ant_ninja.gif'
text: 'A ninja thrower ant costs 10 food units to deploy and dies after throwing four leaves. It will only throw leaves outward, away from the queen. However, each leaf does four times the damage of a leaf thrower.'
text: 'A ninja thrower ant costs 10 food units to deploy and dies after throwing four leaves, this ant also regains an additional leaf when kills a bee. It will only throw leaves outward, away from the queen. However, each leaf does twice the damage of a leaf thrower.'
CaptionedSprite:
source: 'assets/ant_wall.gif'
text: 'A wall ant costs 5 food units to deploy and has three times the health of the other ants. This wall ant must be placed next to another ant in order to survive.'
Paragraph:
text: 'To sacrifice an ant, which can be useful if you need space for new deployments, select the sacrifice tool and tap on the ant you want to sacrifice.'
Paragraph:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment