Skip to content
Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
2 parents f845214 + 50ecfa8 commit fc6a84df214927b3f0c9f8a65dc82a480f073971 @elElmo elElmo committed Mar 31, 2013
Showing with 107 additions and 45 deletions.
  1. BIN assets/art/gui/button_attack_highlight.png
  2. BIN assets/art/gui/button_fortify_highlight.png
  3. BIN assets/art/gui/button_reinforce_highlight.png
  4. BIN assets/art/territories/africa/central_africa.png
  5. BIN assets/art/territories/africa/east_africa.png
  6. BIN assets/art/territories/africa/egypt.png
  7. BIN assets/art/territories/africa/madagascar.png
  8. BIN assets/art/territories/africa/north_africa.png
  9. BIN assets/art/territories/africa/south_africa.png
  10. BIN assets/art/territories/asia/afghanistan.png
  11. BIN assets/art/territories/asia/china.png
  12. BIN assets/art/territories/asia/india.png
  13. BIN assets/art/territories/asia/irkutsk.png
  14. BIN assets/art/territories/asia/japan.png
  15. BIN assets/art/territories/asia/kamchatka.png
  16. BIN assets/art/territories/asia/middle_east.png
  17. BIN assets/art/territories/asia/mongolia.png
  18. BIN assets/art/territories/asia/siberia.png
  19. BIN assets/art/territories/asia/southern_asia.png
  20. BIN assets/art/territories/asia/ural.png
  21. BIN assets/art/territories/asia/yakutsk.png
  22. BIN assets/art/territories/australia/eastern_australia.png
  23. BIN assets/art/territories/australia/indonesia.png
  24. BIN assets/art/territories/australia/new_guinea.png
  25. BIN assets/art/territories/australia/western_australia.png
  26. BIN assets/art/territories/europe/great_britain.png
  27. BIN assets/art/territories/europe/iceland.png
  28. BIN assets/art/territories/europe/northern_europe.png
  29. BIN assets/art/territories/europe/russia.png
  30. BIN assets/art/territories/europe/scandinavia.png
  31. BIN assets/art/territories/europe/southern_europe.png
  32. BIN assets/art/territories/europe/western_europe.png
  33. BIN assets/art/territories/north_america/alaska.png
  34. BIN assets/art/territories/north_america/alberta.png
  35. BIN assets/art/territories/north_america/central_america.png
  36. BIN assets/art/territories/north_america/eastern_canada.png
  37. BIN assets/art/territories/north_america/eastern_united_states.png
  38. BIN assets/art/territories/north_america/greenland.png
  39. BIN assets/art/territories/north_america/northwest_territory.png
  40. BIN assets/art/territories/north_america/ontario.png
  41. BIN assets/art/territories/north_america/western_united_states.png
  42. BIN assets/art/territories/south_america/argentina.png
  43. BIN assets/art/territories/south_america/brazil.png
  44. BIN assets/art/territories/south_america/peru.png
  45. BIN assets/art/territories/south_america/venezuela.png
  46. BIN resources/Border In Progress.png
  47. BIN resources/beige background.png
  48. BIN resources/httpsnees.orgtoolsopenfrescobrowsertrunkGUIblueGradient.pngrev=259.png
  49. BIN resources/risk_board - Copy.png
  50. BIN resources/risk_board(before).png
  51. BIN resources/risk_board.png
  52. BIN resources/risk_board_original - edited.png
  53. BIN resources/risk_board_original - edited_black.png
  54. BIN resources/risk_board_original.png
  55. BIN resources/risk_board_transparent.png
  56. +40 −1 risk/ai/bots.py
  57. +18 −2 risk/graphics/assets/territory.py
  58. +42 −42 risk/graphics/graphics.py
  59. +7 −0 sources.txt
View
BIN assets/art/gui/button_attack_highlight.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/gui/button_fortify_highlight.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/gui/button_reinforce_highlight.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/africa/central_africa.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/africa/east_africa.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/africa/egypt.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/africa/madagascar.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/africa/north_africa.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/africa/south_africa.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/asia/afghanistan.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/asia/china.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/asia/india.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/asia/irkutsk.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/asia/japan.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/asia/kamchatka.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/asia/middle_east.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/asia/mongolia.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/asia/siberia.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/asia/southern_asia.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/asia/ural.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/asia/yakutsk.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/australia/eastern_australia.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/australia/indonesia.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/australia/new_guinea.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/australia/western_australia.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/art/territories/europe/great_britain.png
Diff not rendered.
View
BIN assets/art/territories/europe/iceland.png
Diff not rendered.
View
BIN assets/art/territories/europe/northern_europe.png
Diff not rendered.
View
BIN assets/art/territories/europe/russia.png
Diff not rendered.
View
BIN assets/art/territories/europe/scandinavia.png
Diff not rendered.
View
BIN assets/art/territories/europe/southern_europe.png
Diff not rendered.
View
BIN assets/art/territories/europe/western_europe.png
Diff not rendered.
View
BIN assets/art/territories/north_america/alaska.png
Diff not rendered.
View
BIN assets/art/territories/north_america/alberta.png
Diff not rendered.
View
BIN assets/art/territories/north_america/central_america.png
Diff not rendered.
View
BIN assets/art/territories/north_america/eastern_canada.png
Diff not rendered.
View
BIN assets/art/territories/north_america/eastern_united_states.png
Diff not rendered.
View
BIN assets/art/territories/north_america/greenland.png
Diff not rendered.
View
BIN assets/art/territories/north_america/northwest_territory.png
Diff not rendered.
View
BIN assets/art/territories/north_america/ontario.png
Diff not rendered.
View
BIN assets/art/territories/north_america/western_united_states.png
Diff not rendered.
View
BIN assets/art/territories/south_america/argentina.png
Diff not rendered.
View
BIN assets/art/territories/south_america/brazil.png
Diff not rendered.
View
BIN assets/art/territories/south_america/peru.png
Diff not rendered.
View
BIN assets/art/territories/south_america/venezuela.png
Diff not rendered.
View
BIN resources/Border In Progress.png
Diff not rendered.
View
BIN resources/beige background.png
Diff not rendered.
View
BIN resources/httpsnees.orgtoolsopenfrescobrowsertrunkGUIblueGradient.pngrev=259.png
Diff not rendered.
View
BIN resources/risk_board - Copy.png
Diff not rendered.
View
BIN resources/risk_board(before).png
Diff not rendered.
View
BIN resources/risk_board.png
Diff not rendered.
View
BIN resources/risk_board_original - edited.png
Diff not rendered.
View
BIN resources/risk_board_original - edited_black.png
Diff not rendered.
View
BIN resources/risk_board_original.png
Diff not rendered.
View
BIN resources/risk_board_transparent.png
Diff not rendered.
View
41 risk/ai/bots.py
@@ -118,4 +118,43 @@ def deploy_order(self, game_master, number_of_turns, continent):
for territory in game_master.board.continents[continent].values():
if self.reserves > 0:
if territory.owner != self:
- break
+ break
+
+class IanRiskBot(BasicRiskBot):
+ def __init__(self, title):
+ BasicRiskBot.__init__(self, "group bot[%s]" % title)
+
+ def take_turn(self, game_master):
+ self.deploy_reserves(game_master)
+ self.attack_others(game_master)
+
+ def attack_others(self, game_master):
+ territories = game_master.player_territories(self).values()
+ for territory in territories:
+ neighbours = sorted(territory.neighbours.values(), key=lambda x: x.armies)
+ for neighbour in neighbours:
+ if territory.armies > 100:
+ self._attack_all_possible_targets(game_master)
+ elif neighbour.owner != self and territory.armies <= 7 and float(territory.armies) / neighbour.armies >= 2:
+ game_master.player_attack(self, territory.name, neighbour.name)
+ break
+ elif neighbour.owner != self and territory.armies > 7 and float(territory.armies) / neighbour.armies >= 1.75:
+ game_master.player_attack(self, territory.name, neighbour.name)
+ break
+ elif float(territory.armies) / neighbour.armies < 2:
+ break
+
+ def deploy_reserves(self, game_master):
+ self.deploy_all_to_continent(game_master, 'africa')
+ self.deploy_all_to_continent(game_master, 'asia')
+ self.deploy_all_to_continent(game_master, 'australia')
+ self.deploy_all_to_continent(game_master, 'europe')
+ self.deploy_all_to_continent(game_master, 'north_america')
+ self.deploy_all_to_continent(game_master, 'south_america')
+
+ def deploy_all_to_continent(self, game_master, continent):
+ for territory in game_master.board.continents[continent].values():
+ if self.reserves > 0:
+ if territory.owner == self:
+ print self.reserves
+ game_master.player_add_army(self, territory.name, self.reserves)
View
20 risk/graphics/assets/territory.py
@@ -10,6 +10,8 @@
from risk.graphics.assets.clickable import ClickableAsset
from risk.graphics.assets.text import TextAsset
+import math
+
TERRITORY_ART_ASSET_PATH = './assets/art/territories/'
NO_PLAYER_COLOUR = base.BLACK
@@ -99,7 +101,7 @@ def __init__(self, territory_asset, size=32):
self.count = None
self.size = size
self.colour = base.BLACK
- x = territory_asset.x + territory_asset.surface.get_width() / 2
+ x = territory_asset.x + territory_asset.surface.get_width() / 3
y = territory_asset.y + territory_asset.surface.get_height() / 3
PicassoAsset.__init__(self, None, x, y)
# kinda hacky, we have to rebuild the surface to centre the counter
@@ -108,8 +110,22 @@ def draw(self):
if self.dirty():
self.count = self.territory_asset.territory.armies
font = Font(None, self.size)
- self.surface = font.render(str(self.count), False,
+ dimension = font.size(str(self.count) * 2)
+ text_diagonal_length = math.sqrt(math.pow(dimension[0] / 2, 2) + math.pow(dimension[1], 2))
+ circle_radius = int(math.ceil(text_diagonal_length / 2))
+ #print circle_radius
+ #print dimension [0]
+ self.surface = pygame.Surface([44, 44], pygame.SRCALPHA, 32)
+ self.surface = self.surface.convert_alpha()
+ pygame.draw.circle(self.surface, base.BLACK,
+ (circle_radius, circle_radius),
+ circle_radius)
+ pygame.draw.circle(self.surface, base.WHITE,
+ (circle_radius, circle_radius),
+ circle_radius - 2)
+ font_surface = font.render(str(self.count), False,
self.colour).convert()
+ self.surface.blit(font_surface, (circle_radius - dimension[0] / 4, circle_radius - dimension[1] / 2))
return self.surface
def dirty(self):
View
84 risk/graphics/graphics.py
@@ -30,58 +30,58 @@
territory_coordinates = {
'north_america': {
- 'alaska': (21, 129),
- 'northwest_territory': (103, 112),
- 'greenland': (340, 57),
- 'alberta': (118, 172),
- 'ontario': (232, 173),
- 'eastern_canada': (311, 171),
- 'western_united_states': (169, 228),
- 'eastern_united_states': (250, 223),
- 'central_america': (187, 282)
+ 'alaska': (29, 117),
+ 'northwest_territory': (98, 97),
+ 'greenland': (335, 42),
+ 'alberta': (113, 157),
+ 'ontario': (227, 158),
+ 'eastern_canada': (310, 153),
+ 'western_united_states': (164, 213),
+ 'eastern_united_states': (245, 210),
+ 'central_america': (182, 267)
},
'south_america': {
- 'venezuela': (297, 343),
- 'peru': (296, 386),
- 'brazil': (346, 359),
- 'argentina': (322, 452),
+ 'venezuela': (293, 328),
+ 'peru': (291, 372),
+ 'brazil': (344, 350),
+ 'argentina': (317, 445),
},
'europe': {
- 'iceland': (519, 137),
- 'scandinavia': (585, 130),
- 'russia': (638, 136),
- 'great_britain': (513, 181),
- 'northern_europe': (583, 192),
- 'western_europe': (534, 218),
- 'southern_europe': (600, 222)
+ 'iceland': (517, 122),
+ 'scandinavia': (577, 113),
+ 'russia': (630, 119),
+ 'great_britain': (511, 166),
+ 'northern_europe': (576, 177),
+ 'western_europe': (528, 200),
+ 'southern_europe': (589, 211)
},
'africa': {
- 'north_africa': (511, 265),
- 'egypt': (604, 271),
- 'central_africa': (580, 342),
- 'east_africa': (653, 309),
- 'south_africa': (595, 388),
- 'madagascar': (697, 394)
+ 'north_africa': (504, 251),
+ 'egypt': (603, 253),
+ 'central_africa': (581, 333),
+ 'east_africa': (651, 302),
+ 'south_africa': (601, 395),
+ 'madagascar': (698, 380)
},
'asia': {
- 'ural': (769, 113),
- 'siberia': (799, 91),
- 'yakutsk': (930, 116),
- 'kamchatka': (978, 131),
- 'irkutsk': (877, 163),
- 'afghanistan': (713, 212),
- 'china': (816, 218),
- 'mongolia': (877, 208),
- 'japan': (987, 219),
- 'middle_east': (635, 248),
- 'india': (775, 263),
- 'southern_asia': (852, 295)
+ 'ural': (764, 92),
+ 'siberia': (793, 57),
+ 'yakutsk': (930, 90),
+ 'kamchatka': (983, 115),
+ 'irkutsk': (875, 142),
+ 'afghanistan': (705, 192),
+ 'china': (811, 196),
+ 'mongolia': (871, 182),
+ 'japan': (977, 201),
+ 'middle_east': (644, 230),
+ 'india': (770, 257),
+ 'southern_asia': (847, 274)
},
'australia': {
- 'indonesia': (857, 374),
- 'new_guinea': (1001, 370),
- 'western_australia': (948, 426),
- 'eastern_australia': (1006, 418)
+ 'indonesia': (861, 355),
+ 'new_guinea': (994, 357),
+ 'western_australia': (941, 412),
+ 'eastern_australia': (1004, 402)
}
}
View
7 sources.txt
@@ -0,0 +1,7 @@
+sources:
+
+risk map - http://shanjay.com/?p=114
+
+beige background - http://www.deluzions.net/blog/free-textures-worn-leather/
+
+GUI border -

0 comments on commit fc6a84d

Please sign in to comment.
Something went wrong with that request. Please try again.