Mercurial > rinkhals
annotate gamelib/animal.py @ 448:92e7a641b4a6
added units to price list
author | Adrianna Pińska <adrianna.pinska@gmail.com> |
---|---|
date | Sat, 21 Nov 2009 20:02:33 +0000 |
parents | af2482444945 |
children | fc648da2334c |
rev | line source |
---|---|
25
6d6ab0c1479d
Add placing some chickens and foxes
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
1 """Class for the various animals in the game""" |
6d6ab0c1479d
Add placing some chickens and foxes
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
2 |
84 | 3 import random |
4 | |
25
6d6ab0c1479d
Add placing some chickens and foxes
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
5 from pgu.vid import Sprite |
6d6ab0c1479d
Add placing some chickens and foxes
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
6 |
44
7e884084e7b1
Move animal sprites to imagecache.
Simon Cross <hodgestar@gmail.com>
parents:
38
diff
changeset
|
7 import imagecache |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
8 import tiles |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
9 from misc import Position |
98
725b292ca07b
Added sounds killing foxes and chickens, and nightfall
David Fraser <davidf@sjsoft.com>
parents:
92
diff
changeset
|
10 import sound |
109
48019afde338
Equipment purchasing and some toolbar tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
108
diff
changeset
|
11 import equipment |
241
1a7000c8211c
Demolition foxes, including better fox selection.
Jeremy Thurgood <firxen@gmail.com>
parents:
236
diff
changeset
|
12 import animations |
415
8f012ef1f64f
Start of ability to serialize game state.
Simon Cross <hodgestar@gmail.com>
parents:
414
diff
changeset
|
13 import serializer |
438
16437cf4a2b8
Trees provide a modicum of cover.
Jeremy Thurgood <firxen@gmail.com>
parents:
437
diff
changeset
|
14 import constants |
25
6d6ab0c1479d
Add placing some chickens and foxes
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
15 |
415
8f012ef1f64f
Start of ability to serialize game state.
Simon Cross <hodgestar@gmail.com>
parents:
414
diff
changeset
|
16 class Animal(Sprite, serializer.Simplifiable): |
28
ac3a74352b74
Change animal.py to four space indents.
Simon Cross <hodgestar@gmail.com>
parents:
25
diff
changeset
|
17 """Base class for animals""" |
25
6d6ab0c1479d
Add placing some chickens and foxes
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
18 |
114 | 19 STEALTH = 0 |
199
696936621a93
Buildings can affect visual acuity.
Jeremy Thurgood <firxen@gmail.com>
parents:
196
diff
changeset
|
20 VISION_BONUS = 0 |
696936621a93
Buildings can affect visual acuity.
Jeremy Thurgood <firxen@gmail.com>
parents:
196
diff
changeset
|
21 VISION_RANGE_PENALTY = 10 |
114 | 22 |
420
f20ccd43a282
Rework Animal.__init__ to make it easier to unsimplify them.
Simon Cross <hodgestar@gmail.com>
parents:
419
diff
changeset
|
23 # sub-class must set this to the name of an image |
f20ccd43a282
Rework Animal.__init__ to make it easier to unsimplify them.
Simon Cross <hodgestar@gmail.com>
parents:
419
diff
changeset
|
24 # file |
f20ccd43a282
Rework Animal.__init__ to make it easier to unsimplify them.
Simon Cross <hodgestar@gmail.com>
parents:
419
diff
changeset
|
25 IMAGE_FILE = None |
f20ccd43a282
Rework Animal.__init__ to make it easier to unsimplify them.
Simon Cross <hodgestar@gmail.com>
parents:
419
diff
changeset
|
26 |
415
8f012ef1f64f
Start of ability to serialize game state.
Simon Cross <hodgestar@gmail.com>
parents:
414
diff
changeset
|
27 SIMPLIFY = [ |
8f012ef1f64f
Start of ability to serialize game state.
Simon Cross <hodgestar@gmail.com>
parents:
414
diff
changeset
|
28 'pos', |
8f012ef1f64f
Start of ability to serialize game state.
Simon Cross <hodgestar@gmail.com>
parents:
414
diff
changeset
|
29 'equipment', |
8f012ef1f64f
Start of ability to serialize game state.
Simon Cross <hodgestar@gmail.com>
parents:
414
diff
changeset
|
30 'accoutrements', |
8f012ef1f64f
Start of ability to serialize game state.
Simon Cross <hodgestar@gmail.com>
parents:
414
diff
changeset
|
31 'abode', |
8f012ef1f64f
Start of ability to serialize game state.
Simon Cross <hodgestar@gmail.com>
parents:
414
diff
changeset
|
32 'facing', |
8f012ef1f64f
Start of ability to serialize game state.
Simon Cross <hodgestar@gmail.com>
parents:
414
diff
changeset
|
33 ] |
8f012ef1f64f
Start of ability to serialize game state.
Simon Cross <hodgestar@gmail.com>
parents:
414
diff
changeset
|
34 |
420
f20ccd43a282
Rework Animal.__init__ to make it easier to unsimplify them.
Simon Cross <hodgestar@gmail.com>
parents:
419
diff
changeset
|
35 def __init__(self, tile_pos): |
f20ccd43a282
Rework Animal.__init__ to make it easier to unsimplify them.
Simon Cross <hodgestar@gmail.com>
parents:
419
diff
changeset
|
36 # load images |
f20ccd43a282
Rework Animal.__init__ to make it easier to unsimplify them.
Simon Cross <hodgestar@gmail.com>
parents:
419
diff
changeset
|
37 self._image_left = imagecache.load_image(self.IMAGE_FILE) |
f20ccd43a282
Rework Animal.__init__ to make it easier to unsimplify them.
Simon Cross <hodgestar@gmail.com>
parents:
419
diff
changeset
|
38 self._image_right = imagecache.load_image(self.IMAGE_FILE, ("right_facing",)) |
38
03121c89d5fd
Make the secret foxes really secret
Neil Muller <drnlmuller@gmail.com>
parents:
32
diff
changeset
|
39 # Create the animal somewhere far off screen |
420
f20ccd43a282
Rework Animal.__init__ to make it easier to unsimplify them.
Simon Cross <hodgestar@gmail.com>
parents:
419
diff
changeset
|
40 Sprite.__init__(self, self._image_left, (-1000, -1000)) |
f20ccd43a282
Rework Animal.__init__ to make it easier to unsimplify them.
Simon Cross <hodgestar@gmail.com>
parents:
419
diff
changeset
|
41 self.image_left = self._image_left.copy() |
f20ccd43a282
Rework Animal.__init__ to make it easier to unsimplify them.
Simon Cross <hodgestar@gmail.com>
parents:
419
diff
changeset
|
42 self.image_right = self._image_right.copy() |
395
2d0ff46118e2
Basic support for z coordinate
Neil Muller <drnlmuller@gmail.com>
parents:
394
diff
changeset
|
43 if hasattr(tile_pos, 'to_tile_tuple'): |
171
9ea53eb919cf
Make Animals accept Positions when created. move hatch watching from Chicken to Egg
Neil Muller <drnlmuller@gmail.com>
parents:
163
diff
changeset
|
44 self.pos = tile_pos |
9ea53eb919cf
Make Animals accept Positions when created. move hatch watching from Chicken to Egg
Neil Muller <drnlmuller@gmail.com>
parents:
163
diff
changeset
|
45 else: |
395
2d0ff46118e2
Basic support for z coordinate
Neil Muller <drnlmuller@gmail.com>
parents:
394
diff
changeset
|
46 self.pos = Position(tile_pos[0], tile_pos[1], 0) |
84 | 47 self.equipment = [] |
195
9d31cfc3afde
refactor of layers drawn on chicken, to allow for extended functionality
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
187
diff
changeset
|
48 self.accoutrements = [] |
108
437cbd856a03
Add occupants and abodes. Allowing moving chickens around.
Simon Cross <hodgestar@gmail.com>
parents:
104
diff
changeset
|
49 self.abode = None |
146 | 50 self.facing = 'left' |
25
6d6ab0c1479d
Add placing some chickens and foxes
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
51 |
423
97dd557504a2
Override make methods for simplifiable objects.
Simon Cross <hodgestar@gmail.com>
parents:
422
diff
changeset
|
52 def make(cls): |
97dd557504a2
Override make methods for simplifiable objects.
Simon Cross <hodgestar@gmail.com>
parents:
422
diff
changeset
|
53 """Override default Simplifiable object creation.""" |
97dd557504a2
Override make methods for simplifiable objects.
Simon Cross <hodgestar@gmail.com>
parents:
422
diff
changeset
|
54 return cls((0, 0)) |
97dd557504a2
Override make methods for simplifiable objects.
Simon Cross <hodgestar@gmail.com>
parents:
422
diff
changeset
|
55 make = classmethod(make) |
97dd557504a2
Override make methods for simplifiable objects.
Simon Cross <hodgestar@gmail.com>
parents:
422
diff
changeset
|
56 |
439
cf4b020e6385
Start of serializer for buildings and support for reference cycles.
Simon Cross <hodgestar@gmail.com>
parents:
438
diff
changeset
|
57 def unsimplify(cls, *args, **kwargs): |
427
e89a1afe4e84
Make Position simplifiable. Override unsimplify for animals to update their image after recreating.
Simon Cross <hodgestar@gmail.com>
parents:
426
diff
changeset
|
58 """Override default Simplifiable unsimplification.""" |
439
cf4b020e6385
Start of serializer for buildings and support for reference cycles.
Simon Cross <hodgestar@gmail.com>
parents:
438
diff
changeset
|
59 obj = super(Animal, cls).unsimplify(*args, **kwargs) |
427
e89a1afe4e84
Make Position simplifiable. Override unsimplify for animals to update their image after recreating.
Simon Cross <hodgestar@gmail.com>
parents:
426
diff
changeset
|
60 obj.redraw() |
e89a1afe4e84
Make Position simplifiable. Override unsimplify for animals to update their image after recreating.
Simon Cross <hodgestar@gmail.com>
parents:
426
diff
changeset
|
61 return obj |
e89a1afe4e84
Make Position simplifiable. Override unsimplify for animals to update their image after recreating.
Simon Cross <hodgestar@gmail.com>
parents:
426
diff
changeset
|
62 unsimplify = classmethod(unsimplify) |
e89a1afe4e84
Make Position simplifiable. Override unsimplify for animals to update their image after recreating.
Simon Cross <hodgestar@gmail.com>
parents:
426
diff
changeset
|
63 |
28
ac3a74352b74
Change animal.py to four space indents.
Simon Cross <hodgestar@gmail.com>
parents:
25
diff
changeset
|
64 def loop(self, tv, _sprite): |
395
2d0ff46118e2
Basic support for z coordinate
Neil Muller <drnlmuller@gmail.com>
parents:
394
diff
changeset
|
65 ppos = tv.tile_to_view(self.pos.to_tile_tuple()) |
28
ac3a74352b74
Change animal.py to four space indents.
Simon Cross <hodgestar@gmail.com>
parents:
25
diff
changeset
|
66 self.rect.x = ppos[0] |
ac3a74352b74
Change animal.py to four space indents.
Simon Cross <hodgestar@gmail.com>
parents:
25
diff
changeset
|
67 self.rect.y = ppos[1] |
25
6d6ab0c1479d
Add placing some chickens and foxes
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
68 |
251
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
69 def die(self, gameboard): |
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
70 """Play death animation, noises, whatever.""" |
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
71 if hasattr(self, 'DEATH_SOUND'): |
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
72 sound.play_sound(self.DEATH_SOUND) |
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
73 if hasattr(self, 'DEATH_ANIMATION'): |
395
2d0ff46118e2
Basic support for z coordinate
Neil Muller <drnlmuller@gmail.com>
parents:
394
diff
changeset
|
74 self.DEATH_ANIMATION(gameboard.tv, self.pos.to_tile_tuple()) |
251
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
75 self._game_death(gameboard) |
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
76 |
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
77 def _game_death(self, gameboard): |
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
78 # Call appropriate gameboard cleanup here. |
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
79 pass |
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
80 |
28
ac3a74352b74
Change animal.py to four space indents.
Simon Cross <hodgestar@gmail.com>
parents:
25
diff
changeset
|
81 def move(self, state): |
ac3a74352b74
Change animal.py to four space indents.
Simon Cross <hodgestar@gmail.com>
parents:
25
diff
changeset
|
82 """Given the game state, return a new position for the object""" |
ac3a74352b74
Change animal.py to four space indents.
Simon Cross <hodgestar@gmail.com>
parents:
25
diff
changeset
|
83 # Default is not to move |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
84 pass |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
85 |
396
19e583e5cdc0
Refactor for further move work
Neil Muller <drnlmuller@gmail.com>
parents:
395
diff
changeset
|
86 def attack(self, gameboard): |
19e583e5cdc0
Refactor for further move work
Neil Muller <drnlmuller@gmail.com>
parents:
395
diff
changeset
|
87 """Given the game state, attack a suitable target""" |
19e583e5cdc0
Refactor for further move work
Neil Muller <drnlmuller@gmail.com>
parents:
395
diff
changeset
|
88 # Default is not to attack |
19e583e5cdc0
Refactor for further move work
Neil Muller <drnlmuller@gmail.com>
parents:
395
diff
changeset
|
89 pass |
19e583e5cdc0
Refactor for further move work
Neil Muller <drnlmuller@gmail.com>
parents:
395
diff
changeset
|
90 |
108
437cbd856a03
Add occupants and abodes. Allowing moving chickens around.
Simon Cross <hodgestar@gmail.com>
parents:
104
diff
changeset
|
91 def set_pos(self, tile_pos): |
437cbd856a03
Add occupants and abodes. Allowing moving chickens around.
Simon Cross <hodgestar@gmail.com>
parents:
104
diff
changeset
|
92 """Move an animal to the given tile_pos.""" |
437cbd856a03
Add occupants and abodes. Allowing moving chickens around.
Simon Cross <hodgestar@gmail.com>
parents:
104
diff
changeset
|
93 new_pos = Position(*tile_pos) |
437cbd856a03
Add occupants and abodes. Allowing moving chickens around.
Simon Cross <hodgestar@gmail.com>
parents:
104
diff
changeset
|
94 self._fix_face(new_pos) |
437cbd856a03
Add occupants and abodes. Allowing moving chickens around.
Simon Cross <hodgestar@gmail.com>
parents:
104
diff
changeset
|
95 self.pos = new_pos |
437cbd856a03
Add occupants and abodes. Allowing moving chickens around.
Simon Cross <hodgestar@gmail.com>
parents:
104
diff
changeset
|
96 |
236
9a6ac9c9ff46
chickens turn to face target foxes
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
216
diff
changeset
|
97 def _fix_face(self, facing_pos): |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
98 """Set the face correctly""" |
236
9a6ac9c9ff46
chickens turn to face target foxes
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
216
diff
changeset
|
99 if facing_pos.left_of(self.pos): |
146 | 100 self._set_image_facing('left') |
236
9a6ac9c9ff46
chickens turn to face target foxes
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
216
diff
changeset
|
101 elif facing_pos.right_of(self.pos): |
146 | 102 self._set_image_facing('right') |
103 | |
104 def _set_image_facing(self, facing): | |
105 self.facing = facing | |
106 if self.facing == 'left': | |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
107 self.setimage(self.image_left) |
146 | 108 elif self.facing == 'right': |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
109 self.setimage(self.image_right) |
25
6d6ab0c1479d
Add placing some chickens and foxes
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
110 |
84 | 111 def equip(self, item): |
200
67d10f7e0159
selected chickens are selected
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
199
diff
changeset
|
112 if equipment.is_equipment(item): |
67d10f7e0159
selected chickens are selected
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
199
diff
changeset
|
113 self.equipment.append(item) |
67d10f7e0159
selected chickens are selected
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
199
diff
changeset
|
114 elif equipment.is_accoutrement(item): |
67d10f7e0159
selected chickens are selected
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
199
diff
changeset
|
115 self.accoutrements.append(item) |
163
0d6e23dcd3af
fixed redrawing
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
161
diff
changeset
|
116 self.redraw() |
161
9b4213f6ea7f
improved equipment layers; unequip method on animal
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
158
diff
changeset
|
117 |
9b4213f6ea7f
improved equipment layers; unequip method on animal
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
158
diff
changeset
|
118 def unequip(self, item): |
200
67d10f7e0159
selected chickens are selected
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
199
diff
changeset
|
119 if equipment.is_equipment(item): |
67d10f7e0159
selected chickens are selected
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
199
diff
changeset
|
120 self.equipment = [e for e in self.equipment if e != item] |
67d10f7e0159
selected chickens are selected
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
199
diff
changeset
|
121 elif equipment.is_accoutrement(item): |
67d10f7e0159
selected chickens are selected
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
199
diff
changeset
|
122 self.accoutrements = [e for e in self.accoutrements if e != item] |
163
0d6e23dcd3af
fixed redrawing
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
161
diff
changeset
|
123 self.redraw() |
161
9b4213f6ea7f
improved equipment layers; unequip method on animal
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
158
diff
changeset
|
124 |
200
67d10f7e0159
selected chickens are selected
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
199
diff
changeset
|
125 def unequip_by_name(self, item_name): |
67d10f7e0159
selected chickens are selected
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
199
diff
changeset
|
126 # only remove first match |
67d10f7e0159
selected chickens are selected
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
199
diff
changeset
|
127 matches = [item for item in self.equipment + self.accoutrements if item.NAME == item_name] |
67d10f7e0159
selected chickens are selected
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
199
diff
changeset
|
128 if matches: |
67d10f7e0159
selected chickens are selected
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
199
diff
changeset
|
129 self.unequip(matches[0]) |
67d10f7e0159
selected chickens are selected
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
199
diff
changeset
|
130 |
163
0d6e23dcd3af
fixed redrawing
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
161
diff
changeset
|
131 def redraw(self): |
195
9d31cfc3afde
refactor of layers drawn on chicken, to allow for extended functionality
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
187
diff
changeset
|
132 layers = [(self._image_left.copy(), self._image_right.copy(), 0)] |
9d31cfc3afde
refactor of layers drawn on chicken, to allow for extended functionality
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
187
diff
changeset
|
133 if hasattr(self, 'EQUIPMENT_IMAGE_ATTRIBUTE'): |
9d31cfc3afde
refactor of layers drawn on chicken, to allow for extended functionality
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
187
diff
changeset
|
134 for item in self.accoutrements + self.equipment: |
9d31cfc3afde
refactor of layers drawn on chicken, to allow for extended functionality
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
187
diff
changeset
|
135 images = item.images(self.EQUIPMENT_IMAGE_ATTRIBUTE) |
9d31cfc3afde
refactor of layers drawn on chicken, to allow for extended functionality
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
187
diff
changeset
|
136 if images: |
9d31cfc3afde
refactor of layers drawn on chicken, to allow for extended functionality
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
187
diff
changeset
|
137 layers.append(images) |
158
baf857805867
armour works now
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
149
diff
changeset
|
138 |
195
9d31cfc3afde
refactor of layers drawn on chicken, to allow for extended functionality
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
187
diff
changeset
|
139 layers.sort(key=lambda l: l[2]) |
9d31cfc3afde
refactor of layers drawn on chicken, to allow for extended functionality
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
187
diff
changeset
|
140 |
201
fe1e9c18d4d7
layering bugfix; indoor chickens now use normal chicken icons
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
200
diff
changeset
|
141 # these always go on the bottom so that other layers don't get overwritten |
fe1e9c18d4d7
layering bugfix; indoor chickens now use normal chicken icons
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
200
diff
changeset
|
142 self.image_left = self._image_left.copy() |
fe1e9c18d4d7
layering bugfix; indoor chickens now use normal chicken icons
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
200
diff
changeset
|
143 self.image_right = self._image_right.copy() |
fe1e9c18d4d7
layering bugfix; indoor chickens now use normal chicken icons
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
200
diff
changeset
|
144 for l in layers: |
195
9d31cfc3afde
refactor of layers drawn on chicken, to allow for extended functionality
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
187
diff
changeset
|
145 self.image_left.blit(l[0], (0,0)) |
9d31cfc3afde
refactor of layers drawn on chicken, to allow for extended functionality
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
187
diff
changeset
|
146 self.image_right.blit(l[1], (0,0)) |
9d31cfc3afde
refactor of layers drawn on chicken, to allow for extended functionality
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
187
diff
changeset
|
147 |
9d31cfc3afde
refactor of layers drawn on chicken, to allow for extended functionality
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
187
diff
changeset
|
148 self._set_image_facing(self.facing) |
84 | 149 |
150 def weapons(self): | |
109
48019afde338
Equipment purchasing and some toolbar tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
108
diff
changeset
|
151 return [e for e in self.equipment if equipment.is_weapon(e)] |
84 | 152 |
174
ff168162974e
armour gets damaged
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
171
diff
changeset
|
153 def armour(self): |
ff168162974e
armour gets damaged
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
171
diff
changeset
|
154 return [e for e in self.equipment if equipment.is_armour(e)] |
ff168162974e
armour gets damaged
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
171
diff
changeset
|
155 |
104
d17375586866
Add .covers(tile_pos) to animals (to match similar function on buildings).
Simon Cross <hodgestar@gmail.com>
parents:
98
diff
changeset
|
156 def covers(self, tile_pos): |
d17375586866
Add .covers(tile_pos) to animals (to match similar function on buildings).
Simon Cross <hodgestar@gmail.com>
parents:
98
diff
changeset
|
157 return tile_pos[0] == self.pos.x and tile_pos[1] == self.pos.y |
d17375586866
Add .covers(tile_pos) to animals (to match similar function on buildings).
Simon Cross <hodgestar@gmail.com>
parents:
98
diff
changeset
|
158 |
125 | 159 def outside(self): |
160 return self.abode is None | |
161 | |
251
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
162 def damage(self, gameboard): |
174
ff168162974e
armour gets damaged
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
171
diff
changeset
|
163 for a in self.armour(): |
ff168162974e
armour gets damaged
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
171
diff
changeset
|
164 if not a.survive_damage(): |
ff168162974e
armour gets damaged
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
171
diff
changeset
|
165 self.unequip(a) |
ff168162974e
armour gets damaged
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
171
diff
changeset
|
166 return True |
251
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
167 self.die(gameboard) |
174
ff168162974e
armour gets damaged
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
171
diff
changeset
|
168 return False |
ff168162974e
armour gets damaged
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
171
diff
changeset
|
169 |
25
6d6ab0c1479d
Add placing some chickens and foxes
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
170 class Chicken(Animal): |
28
ac3a74352b74
Change animal.py to four space indents.
Simon Cross <hodgestar@gmail.com>
parents:
25
diff
changeset
|
171 """A chicken""" |
25
6d6ab0c1479d
Add placing some chickens and foxes
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
172 |
146 | 173 EQUIPMENT_IMAGE_ATTRIBUTE = 'CHICKEN_IMAGE_FILE' |
251
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
174 DEATH_ANIMATION = animations.ChickenDeath |
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
175 DEATH_SOUND = 'kill-chicken.ogg' |
420
f20ccd43a282
Rework Animal.__init__ to make it easier to unsimplify them.
Simon Cross <hodgestar@gmail.com>
parents:
419
diff
changeset
|
176 IMAGE_FILE = 'sprites/chkn.png' |
146 | 177 |
426
d34be925b9fc
Fix SIMPLIFY for chickens and eggs. Clean-up greedy fox cost overriding.
Simon Cross <hodgestar@gmail.com>
parents:
423
diff
changeset
|
178 SIMPLIFY = Animal.SIMPLIFY + ['eggs'] |
d34be925b9fc
Fix SIMPLIFY for chickens and eggs. Clean-up greedy fox cost overriding.
Simon Cross <hodgestar@gmail.com>
parents:
423
diff
changeset
|
179 |
28
ac3a74352b74
Change animal.py to four space indents.
Simon Cross <hodgestar@gmail.com>
parents:
25
diff
changeset
|
180 def __init__(self, pos): |
420
f20ccd43a282
Rework Animal.__init__ to make it easier to unsimplify them.
Simon Cross <hodgestar@gmail.com>
parents:
419
diff
changeset
|
181 Animal.__init__(self, pos) |
243
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
182 self.eggs = [] |
25
6d6ab0c1479d
Add placing some chickens and foxes
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
183 |
414
9096c237928c
Dear most illustrious brother, I seek your cooperation with the refactoring of egg layerings and the reloading of guns. Please to provide bank details.
Jeremy Thurgood <firxen@gmail.com>
parents:
413
diff
changeset
|
184 def start_night(self, gameboard): |
9096c237928c
Dear most illustrious brother, I seek your cooperation with the refactoring of egg layerings and the reloading of guns. Please to provide bank details.
Jeremy Thurgood <firxen@gmail.com>
parents:
413
diff
changeset
|
185 self.lay(gameboard) |
9096c237928c
Dear most illustrious brother, I seek your cooperation with the refactoring of egg layerings and the reloading of guns. Please to provide bank details.
Jeremy Thurgood <firxen@gmail.com>
parents:
413
diff
changeset
|
186 self.reload_weapon() |
9096c237928c
Dear most illustrious brother, I seek your cooperation with the refactoring of egg layerings and the reloading of guns. Please to provide bank details.
Jeremy Thurgood <firxen@gmail.com>
parents:
413
diff
changeset
|
187 |
419
d110d55c8449
Move hatching logic into chickens.
Jeremy Thurgood <firxen@gmail.com>
parents:
415
diff
changeset
|
188 def start_day(self, gameboard): |
d110d55c8449
Move hatching logic into chickens.
Jeremy Thurgood <firxen@gmail.com>
parents:
415
diff
changeset
|
189 self.hatch(gameboard) |
d110d55c8449
Move hatching logic into chickens.
Jeremy Thurgood <firxen@gmail.com>
parents:
415
diff
changeset
|
190 |
251
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
191 def _game_death(self, gameboard): |
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
192 gameboard.remove_chicken(self) |
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
193 |
28
ac3a74352b74
Change animal.py to four space indents.
Simon Cross <hodgestar@gmail.com>
parents:
25
diff
changeset
|
194 def move(self, gameboard): |
422
ab4fc3fe0f96
chickens scatter; chop wood
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
420
diff
changeset
|
195 """A free chicken will wander around aimlessly""" |
ab4fc3fe0f96
chickens scatter; chop wood
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
420
diff
changeset
|
196 pos_x, pos_y = self.pos.to_tile_tuple() |
ab4fc3fe0f96
chickens scatter; chop wood
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
420
diff
changeset
|
197 surrounds = [Position(pos_x + dx, pos_y + dy) for dx in [-1, 0, 1] for dy in [-1, 0, 1]] |
ab4fc3fe0f96
chickens scatter; chop wood
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
420
diff
changeset
|
198 pos_options = [pos for pos in surrounds if gameboard.in_bounds(pos) and gameboard.tv.get(pos.to_tile_tuple()) == gameboard.GRASSLAND and not gameboard.get_outside_chicken(pos.to_tile_tuple())] + [self.pos] |
ab4fc3fe0f96
chickens scatter; chop wood
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
420
diff
changeset
|
199 self.pos = pos_options[random.randint(0, len(pos_options)-1)] |
ab4fc3fe0f96
chickens scatter; chop wood
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
420
diff
changeset
|
200 |
441
7b5e4b6dd889
fixed unarmed logging bug
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
439
diff
changeset
|
201 def has_axe(self): |
445 | 202 return bool([e for e in self.weapons() if e.TYPE == "AXE"]) |
441
7b5e4b6dd889
fixed unarmed logging bug
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
439
diff
changeset
|
203 |
422
ab4fc3fe0f96
chickens scatter; chop wood
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
420
diff
changeset
|
204 def chop(self, gameboard): |
441
7b5e4b6dd889
fixed unarmed logging bug
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
439
diff
changeset
|
205 if self.has_axe(): |
7b5e4b6dd889
fixed unarmed logging bug
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
439
diff
changeset
|
206 pos_x, pos_y = self.pos.to_tile_tuple() |
7b5e4b6dd889
fixed unarmed logging bug
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
439
diff
changeset
|
207 surrounds = [Position(pos_x + dx, pos_y + dy) for dx in [-1, 0, 1] for dy in [-1, 0, 1]] |
7b5e4b6dd889
fixed unarmed logging bug
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
439
diff
changeset
|
208 tree_options = [pos for pos in surrounds if gameboard.in_bounds(pos) and gameboard.tv.get(pos.to_tile_tuple()) == gameboard.WOODLAND] |
7b5e4b6dd889
fixed unarmed logging bug
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
439
diff
changeset
|
209 if tree_options: |
7b5e4b6dd889
fixed unarmed logging bug
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
439
diff
changeset
|
210 num_trees_to_cut = random.randint(1, len(tree_options)) |
7b5e4b6dd889
fixed unarmed logging bug
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
439
diff
changeset
|
211 trees_to_cut = random.sample(tree_options, num_trees_to_cut) |
7b5e4b6dd889
fixed unarmed logging bug
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
439
diff
changeset
|
212 for tree_pos in trees_to_cut: |
7b5e4b6dd889
fixed unarmed logging bug
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
439
diff
changeset
|
213 gameboard.add_wood(5) |
7b5e4b6dd889
fixed unarmed logging bug
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
439
diff
changeset
|
214 gameboard.tv.set(tree_pos.to_tile_tuple(), gameboard.GRASSLAND) |
25
6d6ab0c1479d
Add placing some chickens and foxes
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
215 |
414
9096c237928c
Dear most illustrious brother, I seek your cooperation with the refactoring of egg layerings and the reloading of guns. Please to provide bank details.
Jeremy Thurgood <firxen@gmail.com>
parents:
413
diff
changeset
|
216 def lay(self, gameboard): |
116
d539ef5a3333
Add basic chicken->egg cycle
Neil Muller <drnlmuller@gmail.com>
parents:
115
diff
changeset
|
217 """See if the chicken lays an egg""" |
414
9096c237928c
Dear most illustrious brother, I seek your cooperation with the refactoring of egg layerings and the reloading of guns. Please to provide bank details.
Jeremy Thurgood <firxen@gmail.com>
parents:
413
diff
changeset
|
218 if self.abode and self.abode.building.HENHOUSE: |
9096c237928c
Dear most illustrious brother, I seek your cooperation with the refactoring of egg layerings and the reloading of guns. Please to provide bank details.
Jeremy Thurgood <firxen@gmail.com>
parents:
413
diff
changeset
|
219 if not self.eggs: |
9096c237928c
Dear most illustrious brother, I seek your cooperation with the refactoring of egg layerings and the reloading of guns. Please to provide bank details.
Jeremy Thurgood <firxen@gmail.com>
parents:
413
diff
changeset
|
220 for x in range(random.randint(1, 4)): |
9096c237928c
Dear most illustrious brother, I seek your cooperation with the refactoring of egg layerings and the reloading of guns. Please to provide bank details.
Jeremy Thurgood <firxen@gmail.com>
parents:
413
diff
changeset
|
221 self.eggs.append(Egg(self.pos)) |
9096c237928c
Dear most illustrious brother, I seek your cooperation with the refactoring of egg layerings and the reloading of guns. Please to provide bank details.
Jeremy Thurgood <firxen@gmail.com>
parents:
413
diff
changeset
|
222 self.equip(equipment.NestEgg()) |
9096c237928c
Dear most illustrious brother, I seek your cooperation with the refactoring of egg layerings and the reloading of guns. Please to provide bank details.
Jeremy Thurgood <firxen@gmail.com>
parents:
413
diff
changeset
|
223 gameboard.eggs += self.get_num_eggs() |
216
962934b8c7dc
Implement UI part of egg selling
Neil Muller <drnlmuller@gmail.com>
parents:
201
diff
changeset
|
224 |
243
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
225 def remove_eggs(self): |
216
962934b8c7dc
Implement UI part of egg selling
Neil Muller <drnlmuller@gmail.com>
parents:
201
diff
changeset
|
226 """Clean up the egg state""" |
243
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
227 self.eggs = [] |
305
32149b1d9fd2
Capitalised all equipment names.
Jeremy Thurgood <firxen@gmail.com>
parents:
293
diff
changeset
|
228 self.unequip_by_name("Nestegg") |
116
d539ef5a3333
Add basic chicken->egg cycle
Neil Muller <drnlmuller@gmail.com>
parents:
115
diff
changeset
|
229 |
243
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
230 def remove_one_egg(self): |
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
231 """Clean up the egg state""" |
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
232 self.eggs.pop() |
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
233 if not self.eggs: |
305
32149b1d9fd2
Capitalised all equipment names.
Jeremy Thurgood <firxen@gmail.com>
parents:
293
diff
changeset
|
234 self.unequip_by_name("Nestegg") |
243
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
235 |
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
236 def get_num_eggs(self): |
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
237 return len(self.eggs) |
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
238 |
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
239 def hatch(self, gameboard): |
116
d539ef5a3333
Add basic chicken->egg cycle
Neil Muller <drnlmuller@gmail.com>
parents:
115
diff
changeset
|
240 """See if we have an egg to hatch""" |
243
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
241 if self.eggs: |
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
242 chick = self.eggs[0].hatch() |
187 | 243 if chick: |
243
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
244 # sell the remaining eggs |
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
245 # Remove hatched egg |
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
246 self.eggs.pop() |
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
247 gameboard.eggs -= 1 |
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
248 # Sell other eggs |
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
249 for egg in self.eggs[:]: |
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
250 gameboard.sell_one_egg(self) |
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
251 self.remove_eggs() # clean up stale images, etc. |
419
d110d55c8449
Move hatching logic into chickens.
Jeremy Thurgood <firxen@gmail.com>
parents:
415
diff
changeset
|
252 gameboard.place_hatched_chicken(chick, self.abode.building) |
116
d539ef5a3333
Add basic chicken->egg cycle
Neil Muller <drnlmuller@gmail.com>
parents:
115
diff
changeset
|
253 |
84 | 254 def _find_killable_fox(self, weapon, gameboard): |
255 """Choose a random fox within range of this weapon.""" | |
256 killable_foxes = [] | |
257 for fox in gameboard.foxes: | |
437
95b81e917399
Buildings block line-of-sight, except for occupants.
Jeremy Thurgood <firxen@gmail.com>
parents:
431
diff
changeset
|
258 if not visible(self, fox, gameboard): |
114 | 259 continue |
84 | 260 if weapon.in_range(gameboard, self, fox): |
261 killable_foxes.append(fox) | |
262 if not killable_foxes: | |
263 return None | |
264 return random.choice(killable_foxes) | |
265 | |
266 def attack(self, gameboard): | |
267 """An armed chicken will attack a fox within range.""" | |
268 if not self.weapons(): | |
269 # Not going to take on a fox bare-winged. | |
270 return | |
271 # Choose the first weapon equipped. | |
272 weapon = self.weapons()[0] | |
273 fox = self._find_killable_fox(weapon, gameboard) | |
274 if not fox: | |
275 return | |
236
9a6ac9c9ff46
chickens turn to face target foxes
Adrianna Pińska <adrianna.pinska@gmail.com>
parents:
216
diff
changeset
|
276 self._fix_face(fox.pos) |
84 | 277 if weapon.hit(gameboard, self, fox): |
251
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
278 fox.damage(gameboard) |
84 | 279 |
413
bdc4757e0497
Add Sniper Rifle and give guns limited ammunition.
Jeremy Thurgood <firxen@gmail.com>
parents:
407
diff
changeset
|
280 def reload_weapon(self): |
bdc4757e0497
Add Sniper Rifle and give guns limited ammunition.
Jeremy Thurgood <firxen@gmail.com>
parents:
407
diff
changeset
|
281 """If we have a weapon that takes ammunition, reload it.""" |
bdc4757e0497
Add Sniper Rifle and give guns limited ammunition.
Jeremy Thurgood <firxen@gmail.com>
parents:
407
diff
changeset
|
282 for weapon in self.weapons(): |
429
42777630956a
Add ammo to things serialized and deserialized.
Simon Cross <hodgestar@gmail.com>
parents:
428
diff
changeset
|
283 weapon.refresh_ammo() |
413
bdc4757e0497
Add Sniper Rifle and give guns limited ammunition.
Jeremy Thurgood <firxen@gmail.com>
parents:
407
diff
changeset
|
284 |
25
6d6ab0c1479d
Add placing some chickens and foxes
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
285 class Egg(Animal): |
28
ac3a74352b74
Change animal.py to four space indents.
Simon Cross <hodgestar@gmail.com>
parents:
25
diff
changeset
|
286 """An egg""" |
25
6d6ab0c1479d
Add placing some chickens and foxes
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
287 |
420
f20ccd43a282
Rework Animal.__init__ to make it easier to unsimplify them.
Simon Cross <hodgestar@gmail.com>
parents:
419
diff
changeset
|
288 IMAGE_FILE = 'sprites/equip_egg.png' |
f20ccd43a282
Rework Animal.__init__ to make it easier to unsimplify them.
Simon Cross <hodgestar@gmail.com>
parents:
419
diff
changeset
|
289 |
426
d34be925b9fc
Fix SIMPLIFY for chickens and eggs. Clean-up greedy fox cost overriding.
Simon Cross <hodgestar@gmail.com>
parents:
423
diff
changeset
|
290 SIMPLIFY = Animal.SIMPLIFY + ['timer'] |
d34be925b9fc
Fix SIMPLIFY for chickens and eggs. Clean-up greedy fox cost overriding.
Simon Cross <hodgestar@gmail.com>
parents:
423
diff
changeset
|
291 |
47
be2496df2368
Add egg image to egg sprite.
Simon Cross <hodgestar@gmail.com>
parents:
44
diff
changeset
|
292 def __init__(self, pos): |
420
f20ccd43a282
Rework Animal.__init__ to make it easier to unsimplify them.
Simon Cross <hodgestar@gmail.com>
parents:
419
diff
changeset
|
293 Animal.__init__(self, pos) |
243
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
294 self.timer = 2 |
47
be2496df2368
Add egg image to egg sprite.
Simon Cross <hodgestar@gmail.com>
parents:
44
diff
changeset
|
295 |
28
ac3a74352b74
Change animal.py to four space indents.
Simon Cross <hodgestar@gmail.com>
parents:
25
diff
changeset
|
296 # Eggs don't move |
25
6d6ab0c1479d
Add placing some chickens and foxes
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
297 |
171
9ea53eb919cf
Make Animals accept Positions when created. move hatch watching from Chicken to Egg
Neil Muller <drnlmuller@gmail.com>
parents:
163
diff
changeset
|
298 def hatch(self): |
243
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
299 self.timer -= 1 |
4f86c2616cdf
Variable number of eggs for chickens
Neil Muller <drnlmuller@gmail.com>
parents:
241
diff
changeset
|
300 if self.timer == 0: |
171
9ea53eb919cf
Make Animals accept Positions when created. move hatch watching from Chicken to Egg
Neil Muller <drnlmuller@gmail.com>
parents:
163
diff
changeset
|
301 return Chicken(self.pos) |
9ea53eb919cf
Make Animals accept Positions when created. move hatch watching from Chicken to Egg
Neil Muller <drnlmuller@gmail.com>
parents:
163
diff
changeset
|
302 return None |
9ea53eb919cf
Make Animals accept Positions when created. move hatch watching from Chicken to Egg
Neil Muller <drnlmuller@gmail.com>
parents:
163
diff
changeset
|
303 |
25
6d6ab0c1479d
Add placing some chickens and foxes
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
304 class Fox(Animal): |
28
ac3a74352b74
Change animal.py to four space indents.
Simon Cross <hodgestar@gmail.com>
parents:
25
diff
changeset
|
305 """A fox""" |
25
6d6ab0c1479d
Add placing some chickens and foxes
Neil Muller <drnlmuller@gmail.com>
parents:
diff
changeset
|
306 |
114 | 307 STEALTH = 20 |
130 | 308 IMAGE_FILE = 'sprites/fox.png' |
251
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
309 DEATH_ANIMATION = animations.FoxDeath |
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
310 DEATH_SOUND = 'kill-fox.ogg' |
389
463802281182
Add basic level support (level choosing needs work)
Neil Muller <drnlmuller@gmail.com>
parents:
380
diff
changeset
|
311 CONFIG_NAME = 'fox' |
114 | 312 |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
313 costs = { |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
314 # weighting for movement calculation |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
315 'grassland' : 2, |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
316 'woodland' : 1, # Try to keep to the woods if possible |
72
aa4bd93575d9
Fix some bound checking and tweak movement costs
Neil Muller <drnlmuller@gmail.com>
parents:
71
diff
changeset
|
317 'broken fence' : 2, |
404
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
318 'fence' : 25, |
72
aa4bd93575d9
Fix some bound checking and tweak movement costs
Neil Muller <drnlmuller@gmail.com>
parents:
71
diff
changeset
|
319 'guardtower' : 2, # We can pass under towers |
145
490ede177f50
Tweak fox behaviour around henhouses. Add some memory to avoid the indecisive fox loop
Neil Muller <drnlmuller@gmail.com>
parents:
130
diff
changeset
|
320 'henhouse' : 30, # Don't go into a henhouse unless we're going to |
490ede177f50
Tweak fox behaviour around henhouses. Add some memory to avoid the indecisive fox loop
Neil Muller <drnlmuller@gmail.com>
parents:
130
diff
changeset
|
321 # catch a chicken there |
490ede177f50
Tweak fox behaviour around henhouses. Add some memory to avoid the indecisive fox loop
Neil Muller <drnlmuller@gmail.com>
parents:
130
diff
changeset
|
322 'hendominium' : 30, |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
323 } |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
324 |
28
ac3a74352b74
Change animal.py to four space indents.
Simon Cross <hodgestar@gmail.com>
parents:
25
diff
changeset
|
325 def __init__(self, pos): |
420
f20ccd43a282
Rework Animal.__init__ to make it easier to unsimplify them.
Simon Cross <hodgestar@gmail.com>
parents:
419
diff
changeset
|
326 Animal.__init__(self, pos) |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
327 self.landmarks = [self.pos] |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
328 self.hunting = True |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
329 self.dig_pos = None |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
330 self.tick = 0 |
122
d2b19131d537
Don't continue the night if we're not doing anything anymore
Neil Muller <drnlmuller@gmail.com>
parents:
116
diff
changeset
|
331 self.safe = False |
145
490ede177f50
Tweak fox behaviour around henhouses. Add some memory to avoid the indecisive fox loop
Neil Muller <drnlmuller@gmail.com>
parents:
130
diff
changeset
|
332 self.closest = None |
149
2a1064fae608
More memory for the foxes, to ensure we avoid short loops
Neil Muller <drnlmuller@gmail.com>
parents:
146
diff
changeset
|
333 self.last_steps = [] |
397
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
334 # Foxes don't occupy places in the same way chickens do, but they |
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
335 # can still be inside |
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
336 self.building = None |
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
337 |
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
338 def outside(self): |
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
339 return self.building is None |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
340 |
251
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
341 def _game_death(self, gameboard): |
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
342 gameboard.kill_fox(self) |
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
343 |
82
bf28f499c6b4
Tweak fox avoidance behaviour
Neil Muller <drnlmuller@gmail.com>
parents:
72
diff
changeset
|
344 def _cost_tile(self, pos, gameboard): |
bf28f499c6b4
Tweak fox avoidance behaviour
Neil Muller <drnlmuller@gmail.com>
parents:
72
diff
changeset
|
345 if gameboard.in_bounds(pos): |
395
2d0ff46118e2
Basic support for z coordinate
Neil Muller <drnlmuller@gmail.com>
parents:
394
diff
changeset
|
346 this_tile = gameboard.tv.get(pos.to_tile_tuple()) |
82
bf28f499c6b4
Tweak fox avoidance behaviour
Neil Muller <drnlmuller@gmail.com>
parents:
72
diff
changeset
|
347 cost = self.costs.get(tiles.TILE_MAP[this_tile], 100) |
bf28f499c6b4
Tweak fox avoidance behaviour
Neil Muller <drnlmuller@gmail.com>
parents:
72
diff
changeset
|
348 else: |
bf28f499c6b4
Tweak fox avoidance behaviour
Neil Muller <drnlmuller@gmail.com>
parents:
72
diff
changeset
|
349 cost = 100 # Out of bounds is expensive |
bf28f499c6b4
Tweak fox avoidance behaviour
Neil Muller <drnlmuller@gmail.com>
parents:
72
diff
changeset
|
350 return cost |
bf28f499c6b4
Tweak fox avoidance behaviour
Neil Muller <drnlmuller@gmail.com>
parents:
72
diff
changeset
|
351 |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
352 def _cost_path(self, path, gameboard): |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
353 """Calculate the cost of a path""" |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
354 total = 0 |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
355 for pos in path: |
82
bf28f499c6b4
Tweak fox avoidance behaviour
Neil Muller <drnlmuller@gmail.com>
parents:
72
diff
changeset
|
356 total += self._cost_tile(pos, gameboard) |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
357 return total |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
358 |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
359 def _gen_path(self, start_pos, final_pos): |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
360 """Construct a direct path from start_pos to final_pos, |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
361 excluding start_pos""" |
431
129de5883524
Moved intermediate position generation to a more suitable location.
Jeremy Thurgood <firxen@gmail.com>
parents:
429
diff
changeset
|
362 return start_pos.intermediate_positions(final_pos) |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
363 |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
364 def _find_best_path_step(self, final_pos, gameboard): |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
365 """Find the cheapest path to final_pos, and return the next step |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
366 along the path.""" |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
367 # We calculate the cost of the direct path |
395
2d0ff46118e2
Basic support for z coordinate
Neil Muller <drnlmuller@gmail.com>
parents:
394
diff
changeset
|
368 if final_pos.z < self.pos.z: |
2d0ff46118e2
Basic support for z coordinate
Neil Muller <drnlmuller@gmail.com>
parents:
394
diff
changeset
|
369 # We need to try heading down. |
2d0ff46118e2
Basic support for z coordinate
Neil Muller <drnlmuller@gmail.com>
parents:
394
diff
changeset
|
370 return Position(self.pos.x, self.pos.y, self.pos.z - 1) |
404
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
371 if final_pos.x == self.pos.x and final_pos.y == self.pos.y and \ |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
372 final_pos.z > self.pos.z: |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
373 # We try heading up |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
374 return Position(self.pos.x, self.pos.y, self.pos.z + 1) |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
375 cur_dist = final_pos.dist(self.pos) |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
376 if cur_dist < 2: |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
377 # We're right ontop of our target, so just go there |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
378 return final_pos |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
379 # Find the cheapest spot close to us that moves us closer to the target |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
380 neighbours = [Position(self.pos.x + x, self.pos.y + y, self.pos.z) for |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
381 x in range(-1, 2) for y in range(-1, 2) if (x, y) != (0, 0)] |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
382 best_pos = self.pos |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
383 min_cost = 1000 |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
384 min_dist = cur_dist |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
385 for point in neighbours: |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
386 dist = point.dist(final_pos) |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
387 if dist < cur_dist: |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
388 cost = self._cost_tile(point, gameboard) |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
389 if cost < min_cost or (min_cost == cost and dist < min_dist): |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
390 # Prefer closest of equal cost points |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
391 min_dist = dist |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
392 min_cost = cost |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
393 best = point |
407
bdc8bc78a796
Handle corner case aroudn entering the map
Neil Muller <drnlmuller@gmail.com>
parents:
406
diff
changeset
|
394 if min_cost < 20 or not gameboard.in_bounds(self.pos): |
bdc8bc78a796
Handle corner case aroudn entering the map
Neil Muller <drnlmuller@gmail.com>
parents:
406
diff
changeset
|
395 # If we're not on the gameboard yet, there's no point in looking |
bdc8bc78a796
Handle corner case aroudn entering the map
Neil Muller <drnlmuller@gmail.com>
parents:
406
diff
changeset
|
396 # for an optimal path. |
404
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
397 return best |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
398 # Else expensive step, so think further |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
399 direct_path = self._gen_path(self.pos, final_pos) |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
400 min_cost = self._cost_path(direct_path, gameboard) |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
401 min_path = direct_path |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
402 # is there a point nearby that gives us a cheaper direct path? |
71 | 403 # This is delibrately not finding the optimal path, as I don't |
404 # want the foxes to be too intelligent, although the implementation | |
405 # isn't well optimised yet | |
404
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
406 # FIXME: Currently, this introduces loops, but the memory kind |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
407 # avoids that. Fixing this is the next goal. |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
408 poss = [Position(self.pos.x + x, self.pos.y + y, self.pos.z) for |
e5247ec76f24
The new faster deciding (but somewhat dumber) fox
Neil Muller <drnlmuller@gmail.com>
parents:
402
diff
changeset
|
409 x in range(-3, 4) for y in range(-3, 4) if (x, y) != (0, 0)] |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
410 for start in poss: |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
411 cand_path = self._gen_path(self.pos, start) + \ |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
412 self._gen_path(start, final_pos) |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
413 cost = self._cost_path(cand_path, gameboard) |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
414 if cost < min_cost: |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
415 min_cost = cost |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
416 min_path = cand_path |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
417 if not min_path: |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
418 return final_pos |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
419 return min_path[0] |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
420 |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
421 def _find_path_to_woodland(self, gameboard): |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
422 """Dive back to woodland through the landmarks""" |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
423 # find the closest point to our current location in walked path |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
424 if self.pos == self.landmarks[-1]: |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
425 if len(self.landmarks) > 1: |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
426 self.landmarks.pop() # Moving to the next landmark |
402
3a469d46b820
Tweak safe logic to avoid some corner cases
Neil Muller <drnlmuller@gmail.com>
parents:
401
diff
changeset
|
427 if not gameboard.in_bounds(self.pos) and not self.hunting: |
3a469d46b820
Tweak safe logic to avoid some corner cases
Neil Muller <drnlmuller@gmail.com>
parents:
401
diff
changeset
|
428 # Safely out of sight |
3a469d46b820
Tweak safe logic to avoid some corner cases
Neil Muller <drnlmuller@gmail.com>
parents:
401
diff
changeset
|
429 self.safe = True |
3a469d46b820
Tweak safe logic to avoid some corner cases
Neil Muller <drnlmuller@gmail.com>
parents:
401
diff
changeset
|
430 return self.pos |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
431 return self._find_best_path_step(self.landmarks[-1], gameboard) |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
432 |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
433 def _find_path_to_chicken(self, gameboard): |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
434 """Find the path to the closest chicken""" |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
435 # Find the closest chicken |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
436 min_dist = 999 |
145
490ede177f50
Tweak fox behaviour around henhouses. Add some memory to avoid the indecisive fox loop
Neil Muller <drnlmuller@gmail.com>
parents:
130
diff
changeset
|
437 if self.closest not in gameboard.chickens: |
490ede177f50
Tweak fox behaviour around henhouses. Add some memory to avoid the indecisive fox loop
Neil Muller <drnlmuller@gmail.com>
parents:
130
diff
changeset
|
438 # Either no target, or someone ate it |
196
edcb5edfa0ff
If the closest chicken is gone, clear it.
Jeremy Thurgood <firxen@gmail.com>
parents:
195
diff
changeset
|
439 self.closest = None |
145
490ede177f50
Tweak fox behaviour around henhouses. Add some memory to avoid the indecisive fox loop
Neil Muller <drnlmuller@gmail.com>
parents:
130
diff
changeset
|
440 for chicken in gameboard.chickens: |
490ede177f50
Tweak fox behaviour around henhouses. Add some memory to avoid the indecisive fox loop
Neil Muller <drnlmuller@gmail.com>
parents:
130
diff
changeset
|
441 dist = chicken.pos.dist(self.pos) |
490ede177f50
Tweak fox behaviour around henhouses. Add some memory to avoid the indecisive fox loop
Neil Muller <drnlmuller@gmail.com>
parents:
130
diff
changeset
|
442 if chicken.abode: |
370
b3c90e49a6b7
Foxes are more averse to armed chickens and less averse to indoor chickens.
Jeremy Thurgood <firxen@gmail.com>
parents:
305
diff
changeset
|
443 dist += 5 # Prefer free-ranging chickens |
b3c90e49a6b7
Foxes are more averse to armed chickens and less averse to indoor chickens.
Jeremy Thurgood <firxen@gmail.com>
parents:
305
diff
changeset
|
444 if len(chicken.weapons()) > 0: |
b3c90e49a6b7
Foxes are more averse to armed chickens and less averse to indoor chickens.
Jeremy Thurgood <firxen@gmail.com>
parents:
305
diff
changeset
|
445 dist += 5 # Prefer unarmed chickens |
145
490ede177f50
Tweak fox behaviour around henhouses. Add some memory to avoid the indecisive fox loop
Neil Muller <drnlmuller@gmail.com>
parents:
130
diff
changeset
|
446 if dist < min_dist: |
490ede177f50
Tweak fox behaviour around henhouses. Add some memory to avoid the indecisive fox loop
Neil Muller <drnlmuller@gmail.com>
parents:
130
diff
changeset
|
447 min_dist = dist |
490ede177f50
Tweak fox behaviour around henhouses. Add some memory to avoid the indecisive fox loop
Neil Muller <drnlmuller@gmail.com>
parents:
130
diff
changeset
|
448 self.closest = chicken |
490ede177f50
Tweak fox behaviour around henhouses. Add some memory to avoid the indecisive fox loop
Neil Muller <drnlmuller@gmail.com>
parents:
130
diff
changeset
|
449 if not self.closest: |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
450 # No more chickens, so leave |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
451 self.hunting = False |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
452 return self.pos |
145
490ede177f50
Tweak fox behaviour around henhouses. Add some memory to avoid the indecisive fox loop
Neil Muller <drnlmuller@gmail.com>
parents:
130
diff
changeset
|
453 if self.closest.pos == self.pos: |
396
19e583e5cdc0
Refactor for further move work
Neil Muller <drnlmuller@gmail.com>
parents:
395
diff
changeset
|
454 # No need to move |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
455 return self.pos |
395
2d0ff46118e2
Basic support for z coordinate
Neil Muller <drnlmuller@gmail.com>
parents:
394
diff
changeset
|
456 if self.closest.pos.to_tile_tuple() == self.pos.to_tile_tuple(): |
2d0ff46118e2
Basic support for z coordinate
Neil Muller <drnlmuller@gmail.com>
parents:
394
diff
changeset
|
457 # Only differ in z, so next step is in z |
2d0ff46118e2
Basic support for z coordinate
Neil Muller <drnlmuller@gmail.com>
parents:
394
diff
changeset
|
458 if self.closest.pos.z < self.pos.z: |
2d0ff46118e2
Basic support for z coordinate
Neil Muller <drnlmuller@gmail.com>
parents:
394
diff
changeset
|
459 new_z = self.pos.z - 1 |
2d0ff46118e2
Basic support for z coordinate
Neil Muller <drnlmuller@gmail.com>
parents:
394
diff
changeset
|
460 else: |
2d0ff46118e2
Basic support for z coordinate
Neil Muller <drnlmuller@gmail.com>
parents:
394
diff
changeset
|
461 new_z = self.pos.z + 1 |
2d0ff46118e2
Basic support for z coordinate
Neil Muller <drnlmuller@gmail.com>
parents:
394
diff
changeset
|
462 return Position(self.pos.x, self.pos.y, new_z) |
145
490ede177f50
Tweak fox behaviour around henhouses. Add some memory to avoid the indecisive fox loop
Neil Muller <drnlmuller@gmail.com>
parents:
130
diff
changeset
|
463 return self._find_best_path_step(self.closest.pos, gameboard) |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
464 |
396
19e583e5cdc0
Refactor for further move work
Neil Muller <drnlmuller@gmail.com>
parents:
395
diff
changeset
|
465 def attack(self, gameboard): |
19e583e5cdc0
Refactor for further move work
Neil Muller <drnlmuller@gmail.com>
parents:
395
diff
changeset
|
466 """Attack a chicken""" |
401
7405f7db469f
Tweak fox attack logic - we no longer ignore chickens we accidently step on
Neil Muller <drnlmuller@gmail.com>
parents:
399
diff
changeset
|
467 chicken = gameboard.get_animal_at_pos(self.pos, 'chicken') |
7405f7db469f
Tweak fox attack logic - we no longer ignore chickens we accidently step on
Neil Muller <drnlmuller@gmail.com>
parents:
399
diff
changeset
|
468 if chicken: |
7405f7db469f
Tweak fox attack logic - we no longer ignore chickens we accidently step on
Neil Muller <drnlmuller@gmail.com>
parents:
399
diff
changeset
|
469 # Always attack a chicken we step on, even if not hunting |
7405f7db469f
Tweak fox attack logic - we no longer ignore chickens we accidently step on
Neil Muller <drnlmuller@gmail.com>
parents:
399
diff
changeset
|
470 self._catch_chicken(chicken, gameboard) |
396
19e583e5cdc0
Refactor for further move work
Neil Muller <drnlmuller@gmail.com>
parents:
395
diff
changeset
|
471 |
92
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
472 def _catch_chicken(self, chicken, gameboard): |
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
473 """Catch a chicken""" |
251
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
474 chicken.damage(gameboard) |
145
490ede177f50
Tweak fox behaviour around henhouses. Add some memory to avoid the indecisive fox loop
Neil Muller <drnlmuller@gmail.com>
parents:
130
diff
changeset
|
475 self.closest = None |
92
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
476 self.hunting = False |
149
2a1064fae608
More memory for the foxes, to ensure we avoid short loops
Neil Muller <drnlmuller@gmail.com>
parents:
146
diff
changeset
|
477 self.last_steps = [] # Forget history here |
92
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
478 |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
479 def _update_pos(self, gameboard, new_pos): |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
480 """Update the position, making sure we don't step on other foxes""" |
145
490ede177f50
Tweak fox behaviour around henhouses. Add some memory to avoid the indecisive fox loop
Neil Muller <drnlmuller@gmail.com>
parents:
130
diff
changeset
|
481 if new_pos == self.pos: |
490ede177f50
Tweak fox behaviour around henhouses. Add some memory to avoid the indecisive fox loop
Neil Muller <drnlmuller@gmail.com>
parents:
130
diff
changeset
|
482 # We're not moving, so we can skip all the checks |
149
2a1064fae608
More memory for the foxes, to ensure we avoid short loops
Neil Muller <drnlmuller@gmail.com>
parents:
146
diff
changeset
|
483 return new_pos |
401
7405f7db469f
Tweak fox attack logic - we no longer ignore chickens we accidently step on
Neil Muller <drnlmuller@gmail.com>
parents:
399
diff
changeset
|
484 blocked = gameboard.get_animal_at_pos(new_pos, 'fox') is not None |
399
3294929223bd
Cache fox positions to avoid a repeated loop
Neil Muller <drnlmuller@gmail.com>
parents:
398
diff
changeset
|
485 if not blocked and new_pos.z == self.pos.z: |
3294929223bd
Cache fox positions to avoid a repeated loop
Neil Muller <drnlmuller@gmail.com>
parents:
398
diff
changeset
|
486 # We're only worried about loops when not on a ladder |
3294929223bd
Cache fox positions to avoid a repeated loop
Neil Muller <drnlmuller@gmail.com>
parents:
398
diff
changeset
|
487 blocked = new_pos in self.last_steps |
149
2a1064fae608
More memory for the foxes, to ensure we avoid short loops
Neil Muller <drnlmuller@gmail.com>
parents:
146
diff
changeset
|
488 final_pos = new_pos |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
489 if blocked: |
399
3294929223bd
Cache fox positions to avoid a repeated loop
Neil Muller <drnlmuller@gmail.com>
parents:
398
diff
changeset
|
490 if new_pos.z != self.pos.z: |
3294929223bd
Cache fox positions to avoid a repeated loop
Neil Muller <drnlmuller@gmail.com>
parents:
398
diff
changeset
|
491 # We can only move up and down a ladder |
3294929223bd
Cache fox positions to avoid a repeated loop
Neil Muller <drnlmuller@gmail.com>
parents:
398
diff
changeset
|
492 moves = [Position(self.pos.x, self.pos.y, z) for z |
3294929223bd
Cache fox positions to avoid a repeated loop
Neil Muller <drnlmuller@gmail.com>
parents:
398
diff
changeset
|
493 in range(self.pos.z-1, self.pos.z + 2) if z >= 0] |
3294929223bd
Cache fox positions to avoid a repeated loop
Neil Muller <drnlmuller@gmail.com>
parents:
398
diff
changeset
|
494 else: |
3294929223bd
Cache fox positions to avoid a repeated loop
Neil Muller <drnlmuller@gmail.com>
parents:
398
diff
changeset
|
495 moves = [Position(x, y) for x in range(self.pos.x-1, self.pos.x + 2) |
3294929223bd
Cache fox positions to avoid a repeated loop
Neil Muller <drnlmuller@gmail.com>
parents:
398
diff
changeset
|
496 for y in range(self.pos.y-1, self.pos.y + 2) |
3294929223bd
Cache fox positions to avoid a repeated loop
Neil Muller <drnlmuller@gmail.com>
parents:
398
diff
changeset
|
497 if Position(x,y) != self.pos and |
3294929223bd
Cache fox positions to avoid a repeated loop
Neil Muller <drnlmuller@gmail.com>
parents:
398
diff
changeset
|
498 Position(x, y) not in self.last_steps and |
3294929223bd
Cache fox positions to avoid a repeated loop
Neil Muller <drnlmuller@gmail.com>
parents:
398
diff
changeset
|
499 self.pos.z == 0] |
3294929223bd
Cache fox positions to avoid a repeated loop
Neil Muller <drnlmuller@gmail.com>
parents:
398
diff
changeset
|
500 # find the cheapest point in moves that's not blocked |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
501 final_pos = None |
82
bf28f499c6b4
Tweak fox avoidance behaviour
Neil Muller <drnlmuller@gmail.com>
parents:
72
diff
changeset
|
502 min_cost = 1000 |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
503 for poss in moves: |
401
7405f7db469f
Tweak fox attack logic - we no longer ignore chickens we accidently step on
Neil Muller <drnlmuller@gmail.com>
parents:
399
diff
changeset
|
504 if gameboard.get_animal_at_pos(poss, 'fox'): |
399
3294929223bd
Cache fox positions to avoid a repeated loop
Neil Muller <drnlmuller@gmail.com>
parents:
398
diff
changeset
|
505 continue # blocked |
82
bf28f499c6b4
Tweak fox avoidance behaviour
Neil Muller <drnlmuller@gmail.com>
parents:
72
diff
changeset
|
506 cost = self._cost_tile(poss, gameboard) |
bf28f499c6b4
Tweak fox avoidance behaviour
Neil Muller <drnlmuller@gmail.com>
parents:
72
diff
changeset
|
507 if cost < min_cost: |
bf28f499c6b4
Tweak fox avoidance behaviour
Neil Muller <drnlmuller@gmail.com>
parents:
72
diff
changeset
|
508 min_cost = cost |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
509 final_pos = poss |
257
fcaae2cfe3cd
Make foxes less determistic when avoiding other foxes
Neil Muller <drnlmuller@gmail.com>
parents:
251
diff
changeset
|
510 if cost == min_cost and random.randint(0, 1) > 0: |
fcaae2cfe3cd
Make foxes less determistic when avoiding other foxes
Neil Muller <drnlmuller@gmail.com>
parents:
251
diff
changeset
|
511 # Add some randomness in this case |
fcaae2cfe3cd
Make foxes less determistic when avoiding other foxes
Neil Muller <drnlmuller@gmail.com>
parents:
251
diff
changeset
|
512 final_pos = poss |
149
2a1064fae608
More memory for the foxes, to ensure we avoid short loops
Neil Muller <drnlmuller@gmail.com>
parents:
146
diff
changeset
|
513 if not final_pos: |
2a1064fae608
More memory for the foxes, to ensure we avoid short loops
Neil Muller <drnlmuller@gmail.com>
parents:
146
diff
changeset
|
514 # No good choice, so stay put |
2a1064fae608
More memory for the foxes, to ensure we avoid short loops
Neil Muller <drnlmuller@gmail.com>
parents:
146
diff
changeset
|
515 return self.pos |
72
aa4bd93575d9
Fix some bound checking and tweak movement costs
Neil Muller <drnlmuller@gmail.com>
parents:
71
diff
changeset
|
516 if gameboard.in_bounds(final_pos): |
395
2d0ff46118e2
Basic support for z coordinate
Neil Muller <drnlmuller@gmail.com>
parents:
394
diff
changeset
|
517 this_tile = gameboard.tv.get(final_pos.to_tile_tuple()) |
72
aa4bd93575d9
Fix some bound checking and tweak movement costs
Neil Muller <drnlmuller@gmail.com>
parents:
71
diff
changeset
|
518 else: |
aa4bd93575d9
Fix some bound checking and tweak movement costs
Neil Muller <drnlmuller@gmail.com>
parents:
71
diff
changeset
|
519 this_tile = tiles.REVERSE_TILE_MAP['woodland'] |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
520 if tiles.TILE_MAP[this_tile] == 'broken fence' and self.hunting: |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
521 # We'll head back towards the holes we make/find |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
522 self.landmarks.append(final_pos) |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
523 elif tiles.TILE_MAP[this_tile] == 'fence' and not self.dig_pos: |
241
1a7000c8211c
Demolition foxes, including better fox selection.
Jeremy Thurgood <firxen@gmail.com>
parents:
236
diff
changeset
|
524 self._dig(gameboard, final_pos) |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
525 return self.pos |
149
2a1064fae608
More memory for the foxes, to ensure we avoid short loops
Neil Muller <drnlmuller@gmail.com>
parents:
146
diff
changeset
|
526 self.last_steps.append(final_pos) |
2a1064fae608
More memory for the foxes, to ensure we avoid short loops
Neil Muller <drnlmuller@gmail.com>
parents:
146
diff
changeset
|
527 if len(self.last_steps) > 3: |
2a1064fae608
More memory for the foxes, to ensure we avoid short loops
Neil Muller <drnlmuller@gmail.com>
parents:
146
diff
changeset
|
528 self.last_steps.pop(0) |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
529 return final_pos |
28
ac3a74352b74
Change animal.py to four space indents.
Simon Cross <hodgestar@gmail.com>
parents:
25
diff
changeset
|
530 |
241
1a7000c8211c
Demolition foxes, including better fox selection.
Jeremy Thurgood <firxen@gmail.com>
parents:
236
diff
changeset
|
531 def _dig(self, gameboard, dig_pos): |
92
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
532 """Setup dig parameters, to be overridden if needed""" |
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
533 self.tick = 5 |
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
534 self.dig_pos = dig_pos |
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
535 |
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
536 def _make_hole(self, gameboard): |
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
537 """Make a hole in the fence""" |
395
2d0ff46118e2
Basic support for z coordinate
Neil Muller <drnlmuller@gmail.com>
parents:
394
diff
changeset
|
538 fence = gameboard.get_building(self.dig_pos.to_tile_tuple()) |
394
ad77b3b71b08
Fix crash when multiple foxes finish digging at the same time
Neil Muller <drnlmuller@gmail.com>
parents:
389
diff
changeset
|
539 # Another fox could have made the same hole this turn |
ad77b3b71b08
Fix crash when multiple foxes finish digging at the same time
Neil Muller <drnlmuller@gmail.com>
parents:
389
diff
changeset
|
540 if fence: |
ad77b3b71b08
Fix crash when multiple foxes finish digging at the same time
Neil Muller <drnlmuller@gmail.com>
parents:
389
diff
changeset
|
541 fence.damage(gameboard.tv) |
92
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
542 self.dig_pos = None |
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
543 |
28
ac3a74352b74
Change animal.py to four space indents.
Simon Cross <hodgestar@gmail.com>
parents:
25
diff
changeset
|
544 def move(self, gameboard): |
ac3a74352b74
Change animal.py to four space indents.
Simon Cross <hodgestar@gmail.com>
parents:
25
diff
changeset
|
545 """Foxes will aim to move towards the closest henhouse or free |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
546 chicken""" |
398
082b1ea5f98d
Regain time lost when adding foxes to buildings
Neil Muller <drnlmuller@gmail.com>
parents:
397
diff
changeset
|
547 if self.safe: |
082b1ea5f98d
Regain time lost when adding foxes to buildings
Neil Muller <drnlmuller@gmail.com>
parents:
397
diff
changeset
|
548 # We're safe, so do nothing |
082b1ea5f98d
Regain time lost when adding foxes to buildings
Neil Muller <drnlmuller@gmail.com>
parents:
397
diff
changeset
|
549 return |
082b1ea5f98d
Regain time lost when adding foxes to buildings
Neil Muller <drnlmuller@gmail.com>
parents:
397
diff
changeset
|
550 elif self.dig_pos: |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
551 if self.tick: |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
552 self.tick -= 1 |
92
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
553 # We're still digging through the fence |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
554 # Check the another fox hasn't dug a hole for us |
92
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
555 # We're too busy digging to notice if a hole appears nearby, |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
556 # but we'll notice if the fence we're digging vanishes |
395
2d0ff46118e2
Basic support for z coordinate
Neil Muller <drnlmuller@gmail.com>
parents:
394
diff
changeset
|
557 this_tile = gameboard.tv.get(self.dig_pos.to_tile_tuple()) |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
558 if tiles.TILE_MAP[this_tile] == 'broken fence': |
397
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
559 self.tick = 0 |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
560 else: |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
561 # We've dug through the fence, so make a hole |
92
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
562 self._make_hole(gameboard) |
397
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
563 return |
398
082b1ea5f98d
Regain time lost when adding foxes to buildings
Neil Muller <drnlmuller@gmail.com>
parents:
397
diff
changeset
|
564 elif self.hunting: |
70
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
565 desired_pos = self._find_path_to_chicken(gameboard) |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
566 else: |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
567 desired_pos = self._find_path_to_woodland(gameboard) |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
568 final_pos = self._update_pos(gameboard, desired_pos) |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
569 self._fix_face(final_pos) |
d92a2f973cc4
Make foxes move 'better' and break fences
Neil Muller <drnlmuller@gmail.com>
parents:
53
diff
changeset
|
570 self.pos = final_pos |
398
082b1ea5f98d
Regain time lost when adding foxes to buildings
Neil Muller <drnlmuller@gmail.com>
parents:
397
diff
changeset
|
571 change_visible = False |
397
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
572 # See if we're entering/leaving a building |
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
573 building = gameboard.get_building(final_pos.to_tile_tuple()) |
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
574 if building and self.outside(): |
398
082b1ea5f98d
Regain time lost when adding foxes to buildings
Neil Muller <drnlmuller@gmail.com>
parents:
397
diff
changeset
|
575 # Check if we need to enter |
082b1ea5f98d
Regain time lost when adding foxes to buildings
Neil Muller <drnlmuller@gmail.com>
parents:
397
diff
changeset
|
576 if self.closest and not self.closest.outside() and \ |
082b1ea5f98d
Regain time lost when adding foxes to buildings
Neil Muller <drnlmuller@gmail.com>
parents:
397
diff
changeset
|
577 self.closest.abode.building is building: |
082b1ea5f98d
Regain time lost when adding foxes to buildings
Neil Muller <drnlmuller@gmail.com>
parents:
397
diff
changeset
|
578 building.add_predator(self) |
082b1ea5f98d
Regain time lost when adding foxes to buildings
Neil Muller <drnlmuller@gmail.com>
parents:
397
diff
changeset
|
579 change_visible = True |
397
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
580 elif self.building and final_pos.z == 0: |
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
581 # can only leave from the ground floor |
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
582 if building == self.building: |
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
583 # Check if we need to leave the building |
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
584 if not self.hunting or (self.closest and |
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
585 self.closest.abode.building is not building): |
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
586 self.building.remove_predator(self) |
398
082b1ea5f98d
Regain time lost when adding foxes to buildings
Neil Muller <drnlmuller@gmail.com>
parents:
397
diff
changeset
|
587 change_visible = True |
397
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
588 else: |
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
589 # we've moved away from the building we were in |
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
590 self.building.remove_predator(self) |
398
082b1ea5f98d
Regain time lost when adding foxes to buildings
Neil Muller <drnlmuller@gmail.com>
parents:
397
diff
changeset
|
591 change_visible = True |
082b1ea5f98d
Regain time lost when adding foxes to buildings
Neil Muller <drnlmuller@gmail.com>
parents:
397
diff
changeset
|
592 if change_visible: |
082b1ea5f98d
Regain time lost when adding foxes to buildings
Neil Muller <drnlmuller@gmail.com>
parents:
397
diff
changeset
|
593 gameboard.set_visibility(self) |
397
532f1ea476ff
Make foxes enter buildings, with a seperate count for them
Neil Muller <drnlmuller@gmail.com>
parents:
396
diff
changeset
|
594 |
92
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
595 |
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
596 class NinjaFox(Fox): |
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
597 """Ninja foxes are hard to see""" |
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
598 |
114 | 599 STEALTH = 60 |
130 | 600 IMAGE_FILE = 'sprites/ninja_fox.png' |
389
463802281182
Add basic level support (level choosing needs work)
Neil Muller <drnlmuller@gmail.com>
parents:
380
diff
changeset
|
601 CONFIG_NAME = 'ninja fox' |
114 | 602 |
92
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
603 class DemoFox(Fox): |
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
604 """Demolition Foxes destroy fences easily""" |
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
605 |
241
1a7000c8211c
Demolition foxes, including better fox selection.
Jeremy Thurgood <firxen@gmail.com>
parents:
236
diff
changeset
|
606 DIG_ANIMATION = animations.FenceExplosion |
1a7000c8211c
Demolition foxes, including better fox selection.
Jeremy Thurgood <firxen@gmail.com>
parents:
236
diff
changeset
|
607 IMAGE_FILE = 'sprites/sapper_fox.png' |
389
463802281182
Add basic level support (level choosing needs work)
Neil Muller <drnlmuller@gmail.com>
parents:
380
diff
changeset
|
608 CONFIG_NAME = 'sapper fox' |
241
1a7000c8211c
Demolition foxes, including better fox selection.
Jeremy Thurgood <firxen@gmail.com>
parents:
236
diff
changeset
|
609 |
406
f8072b2d6dd1
Fix bug where sapper foxes overwrite costs for all foxes
Neil Muller <drnlmuller@gmail.com>
parents:
404
diff
changeset
|
610 costs = Fox.costs.copy() |
426
d34be925b9fc
Fix SIMPLIFY for chickens and eggs. Clean-up greedy fox cost overriding.
Simon Cross <hodgestar@gmail.com>
parents:
423
diff
changeset
|
611 costs['fence'] = 2 |
269
445f746449fa
Tweak sapper fox path weighting
Neil Muller <drnlmuller@gmail.com>
parents:
257
diff
changeset
|
612 |
241
1a7000c8211c
Demolition foxes, including better fox selection.
Jeremy Thurgood <firxen@gmail.com>
parents:
236
diff
changeset
|
613 def _dig(self, gameboard, dig_pos): |
1a7000c8211c
Demolition foxes, including better fox selection.
Jeremy Thurgood <firxen@gmail.com>
parents:
236
diff
changeset
|
614 """Setup dig parameters, to be overridden if needed""" |
1a7000c8211c
Demolition foxes, including better fox selection.
Jeremy Thurgood <firxen@gmail.com>
parents:
236
diff
changeset
|
615 self.tick = 0 # Costs us nothing to go through a fence. |
1a7000c8211c
Demolition foxes, including better fox selection.
Jeremy Thurgood <firxen@gmail.com>
parents:
236
diff
changeset
|
616 self.dig_pos = dig_pos |
395
2d0ff46118e2
Basic support for z coordinate
Neil Muller <drnlmuller@gmail.com>
parents:
394
diff
changeset
|
617 self.DIG_ANIMATION(gameboard.tv, dig_pos.to_tile_tuple()) |
241
1a7000c8211c
Demolition foxes, including better fox selection.
Jeremy Thurgood <firxen@gmail.com>
parents:
236
diff
changeset
|
618 self._make_hole(gameboard) |
1a7000c8211c
Demolition foxes, including better fox selection.
Jeremy Thurgood <firxen@gmail.com>
parents:
236
diff
changeset
|
619 |
92
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
620 class GreedyFox(Fox): |
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
621 """Greedy foxes eat more chickens""" |
389
463802281182
Add basic level support (level choosing needs work)
Neil Muller <drnlmuller@gmail.com>
parents:
380
diff
changeset
|
622 CONFIG_NAME = 'greedy fox' |
92
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
623 |
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
624 def __init__(self, pos): |
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
625 Fox.__init__(self, pos) |
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
626 self.chickens_eaten = 0 |
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
627 |
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
628 def _catch_chicken(self, chicken, gameboard): |
251
844bfb23d4b6
Refactored animal death and added death animations.
Jeremy Thurgood <firxen@gmail.com>
parents:
243
diff
changeset
|
629 chicken.damage(gameboard) |
145
490ede177f50
Tweak fox behaviour around henhouses. Add some memory to avoid the indecisive fox loop
Neil Muller <drnlmuller@gmail.com>
parents:
130
diff
changeset
|
630 self.closest = None |
92
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
631 self.chickens_eaten += 1 |
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
632 if self.chickens_eaten > 2: |
bea1b9364583
Refactor Fox so we can have different types. Add a greedy fox
Neil Muller <drnlmuller@gmail.com>
parents:
84
diff
changeset
|
633 self.hunting = False |
149
2a1064fae608
More memory for the foxes, to ensure we avoid short loops
Neil Muller <drnlmuller@gmail.com>
parents:
146
diff
changeset
|
634 self.last_steps = [] |
114 | 635 |
290 | 636 class Rinkhals(Fox): |
637 """The Rinkhals has eclectic tastes""" | |
638 STEALTH = 80 | |
639 IMAGE_FILE = 'sprites/rinkhals.png' | |
389
463802281182
Add basic level support (level choosing needs work)
Neil Muller <drnlmuller@gmail.com>
parents:
380
diff
changeset
|
640 CONFIG_NAME = 'rinkhals' |
290 | 641 |
642 def _catch_chicken(self, chicken, gameboard): | |
643 """The Rinkhals hunts for sport, catch and release style""" | |
644 self.closest = None | |
645 self.hunting = False | |
646 self.last_steps = [] | |
647 | |
648 def _make_hole(self, gameboard): | |
649 """The Rinkhals eats fences""" | |
395
2d0ff46118e2
Basic support for z coordinate
Neil Muller <drnlmuller@gmail.com>
parents:
394
diff
changeset
|
650 fence = gameboard.get_building(self.dig_pos.to_tile_tuple()) |
394
ad77b3b71b08
Fix crash when multiple foxes finish digging at the same time
Neil Muller <drnlmuller@gmail.com>
parents:
389
diff
changeset
|
651 if fence: |
ad77b3b71b08
Fix crash when multiple foxes finish digging at the same time
Neil Muller <drnlmuller@gmail.com>
parents:
389
diff
changeset
|
652 fence.remove(gameboard.tv) |
ad77b3b71b08
Fix crash when multiple foxes finish digging at the same time
Neil Muller <drnlmuller@gmail.com>
parents:
389
diff
changeset
|
653 gameboard.remove_building(fence) |
290 | 654 self.dig_pos = None |
655 | |
656 def damage(self, gameboard): | |
657 """The Rinkhals is invincible!""" | |
658 return True | |
659 | |
199
696936621a93
Buildings can affect visual acuity.
Jeremy Thurgood <firxen@gmail.com>
parents:
196
diff
changeset
|
660 def _get_vision_param(parameter, watcher): |
696936621a93
Buildings can affect visual acuity.
Jeremy Thurgood <firxen@gmail.com>
parents:
196
diff
changeset
|
661 param = getattr(watcher, parameter) |
696936621a93
Buildings can affect visual acuity.
Jeremy Thurgood <firxen@gmail.com>
parents:
196
diff
changeset
|
662 if watcher.abode: |
696936621a93
Buildings can affect visual acuity.
Jeremy Thurgood <firxen@gmail.com>
parents:
196
diff
changeset
|
663 modifier = getattr(watcher.abode.building, 'MODIFY_'+parameter, lambda r: r) |
696936621a93
Buildings can affect visual acuity.
Jeremy Thurgood <firxen@gmail.com>
parents:
196
diff
changeset
|
664 param = modifier(param) |
696936621a93
Buildings can affect visual acuity.
Jeremy Thurgood <firxen@gmail.com>
parents:
196
diff
changeset
|
665 return param |
696936621a93
Buildings can affect visual acuity.
Jeremy Thurgood <firxen@gmail.com>
parents:
196
diff
changeset
|
666 |
437
95b81e917399
Buildings block line-of-sight, except for occupants.
Jeremy Thurgood <firxen@gmail.com>
parents:
431
diff
changeset
|
667 def visible(watcher, watchee, gameboard): |
443
4efe57fcc1d7
Anything off the board is invisible.
Jeremy Thurgood <firxen@gmail.com>
parents:
441
diff
changeset
|
668 if not gameboard.in_bounds(watchee.pos): |
4efe57fcc1d7
Anything off the board is invisible.
Jeremy Thurgood <firxen@gmail.com>
parents:
441
diff
changeset
|
669 # We can't see anything off the edge of the board. |
4efe57fcc1d7
Anything off the board is invisible.
Jeremy Thurgood <firxen@gmail.com>
parents:
441
diff
changeset
|
670 return False |
199
696936621a93
Buildings can affect visual acuity.
Jeremy Thurgood <firxen@gmail.com>
parents:
196
diff
changeset
|
671 vision_bonus = _get_vision_param('VISION_BONUS', watcher) |
696936621a93
Buildings can affect visual acuity.
Jeremy Thurgood <firxen@gmail.com>
parents:
196
diff
changeset
|
672 range_penalty = _get_vision_param('VISION_RANGE_PENALTY', watcher) |
437
95b81e917399
Buildings block line-of-sight, except for occupants.
Jeremy Thurgood <firxen@gmail.com>
parents:
431
diff
changeset
|
673 positions = watcher.pos.intermediate_positions(watchee.pos) |
95b81e917399
Buildings block line-of-sight, except for occupants.
Jeremy Thurgood <firxen@gmail.com>
parents:
431
diff
changeset
|
674 for pos in positions: |
95b81e917399
Buildings block line-of-sight, except for occupants.
Jeremy Thurgood <firxen@gmail.com>
parents:
431
diff
changeset
|
675 building = gameboard.get_building(pos.to_tile_tuple()) |
95b81e917399
Buildings block line-of-sight, except for occupants.
Jeremy Thurgood <firxen@gmail.com>
parents:
431
diff
changeset
|
676 # This allows chickens to fire across GuardTowers and Fences. |
95b81e917399
Buildings block line-of-sight, except for occupants.
Jeremy Thurgood <firxen@gmail.com>
parents:
431
diff
changeset
|
677 if building and building.BLOCKS_VISION and not (watcher in building.occupants()): |
95b81e917399
Buildings block line-of-sight, except for occupants.
Jeremy Thurgood <firxen@gmail.com>
parents:
431
diff
changeset
|
678 return False |
199
696936621a93
Buildings can affect visual acuity.
Jeremy Thurgood <firxen@gmail.com>
parents:
196
diff
changeset
|
679 distance = watcher.pos.dist(watchee.pos) - 1 |
438
16437cf4a2b8
Trees provide a modicum of cover.
Jeremy Thurgood <firxen@gmail.com>
parents:
437
diff
changeset
|
680 # Intervening forests get in the way a bit. |
16437cf4a2b8
Trees provide a modicum of cover.
Jeremy Thurgood <firxen@gmail.com>
parents:
437
diff
changeset
|
681 woods = len([pos for pos in positions if gameboard.tv.get(pos.to_tile_tuple()) == gameboard.WOODLAND]) |
114 | 682 roll = random.randint(1, 100) |
438
16437cf4a2b8
Trees provide a modicum of cover.
Jeremy Thurgood <firxen@gmail.com>
parents:
437
diff
changeset
|
683 return roll > watchee.STEALTH - vision_bonus + range_penalty*distance + constants.WOODLAND_CONCEALMENT*woods |
389
463802281182
Add basic level support (level choosing needs work)
Neil Muller <drnlmuller@gmail.com>
parents:
380
diff
changeset
|
684 |
463802281182
Add basic level support (level choosing needs work)
Neil Muller <drnlmuller@gmail.com>
parents:
380
diff
changeset
|
685 # These don't have to add up to 100, but it's easier to think |
463802281182
Add basic level support (level choosing needs work)
Neil Muller <drnlmuller@gmail.com>
parents:
380
diff
changeset
|
686 # about them if they do. |
463802281182
Add basic level support (level choosing needs work)
Neil Muller <drnlmuller@gmail.com>
parents:
380
diff
changeset
|
687 DEFAULT_FOX_WEIGHTINGS = ( |
463802281182
Add basic level support (level choosing needs work)
Neil Muller <drnlmuller@gmail.com>
parents:
380
diff
changeset
|
688 (Fox, 59), |
463802281182
Add basic level support (level choosing needs work)
Neil Muller <drnlmuller@gmail.com>
parents:
380
diff
changeset
|
689 (GreedyFox, 30), |
463802281182
Add basic level support (level choosing needs work)
Neil Muller <drnlmuller@gmail.com>
parents:
380
diff
changeset
|
690 (NinjaFox, 5), |
463802281182
Add basic level support (level choosing needs work)
Neil Muller <drnlmuller@gmail.com>
parents:
380
diff
changeset
|
691 (DemoFox, 5), |
463802281182
Add basic level support (level choosing needs work)
Neil Muller <drnlmuller@gmail.com>
parents:
380
diff
changeset
|
692 (Rinkhals, 1), |
463802281182
Add basic level support (level choosing needs work)
Neil Muller <drnlmuller@gmail.com>
parents:
380
diff
changeset
|
693 ) |
463802281182
Add basic level support (level choosing needs work)
Neil Muller <drnlmuller@gmail.com>
parents:
380
diff
changeset
|
694 |