From 85d88107f753abd95e4a2f6d219e8791d9193990 Mon Sep 17 00:00:00 2001 From: groot Date: Wed, 11 May 2016 00:29:12 -0700 Subject: [PATCH] Make Hungry Hungry Baubles a Basic Game (Resolves #118) Created Common 'BaubleGame' Base Class for Hungry Hungry Baubles and Bauble Hunt. Made Bauble Hunt and Discovery Quest use new BasicGame's getObjectiveLocation() instead of getHomeBasePosition(). --- SBA_Serv/Game/BaubleGame.py | 86 +++++++++++++++++++ SBA_Serv/Game/BaubleHunt.py | 58 +------------ SBA_Serv/Game/DiscoveryQuest.py | 2 +- SBA_Serv/Game/Game.py | 2 +- SBA_Serv/Game/HungryHungryBaubles.py | 75 ++++------------ SBA_Serv/Game/__init__.py | 2 +- SBA_Serv/SBA_Serv.pyproj | 5 +- SBA_Serv/Tests/BaubleHuntTestCases.py | 2 +- .../Tests/HungryHungryBaublesTestCases.py | 6 +- SBA_Serv/Tests/test_baublehunt.cfg | 8 +- SBA_Serv/Tests/test_hungryhungrybaubles.cfg | 13 ++- SBA_Serv/Tests/test_hungryhungrybaubles2.cfg | 13 ++- ....cfg => basicgame_hungryhungrybaubles.cfg} | 13 ++- SBA_Serv/buildnum | 2 +- SBA_Serv/game_baublehunt.cfg | 14 +-- changelog.md | 8 +- doc/games/basic.md | 3 +- doc/games/baublehunt.md | 23 +++-- doc/games/discoveryquest.md | 2 +- doc/games/hungryhungrybaubles.md | 34 ++++++-- doc/index.md | 2 +- .../ihs/apcs/spacebattle/BasicGameInfo.java | 11 ++- .../spacebattle/games/BaubleHuntGameInfo.java | 9 +- .../games/DiscoveryQuestGameInfo.java | 15 +--- .../games/HungryHungryBaublesGameInfo.java | 32 ------- .../spacebattle/networking/MwnpMessage.java | 3 - 26 files changed, 228 insertions(+), 215 deletions(-) create mode 100644 SBA_Serv/Game/BaubleGame.py rename SBA_Serv/{game_hungryhungrybaubles.cfg => basicgame_hungryhungrybaubles.cfg} (69%) delete mode 100644 java_client_src/src/ihs/apcs/spacebattle/games/HungryHungryBaublesGameInfo.java diff --git a/SBA_Serv/Game/BaubleGame.py b/SBA_Serv/Game/BaubleGame.py new file mode 100644 index 0000000..01d9e3b --- /dev/null +++ b/SBA_Serv/Game/BaubleGame.py @@ -0,0 +1,86 @@ +""" +Space Battle Arena is a Programming Game. + +Copyright (C) 2012-2016 Michael A. Hawker and Brett Wortzman + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +The full text of the license is available online: http://opensource.org/licenses/GPL-2.0 +""" + +from Game import BasicGame +from GUI.ObjWrappers.GUIEntity import GUIEntity +from GUI.GraphicsCache import Cache +from World.WorldMath import intpos, friendly_type, PlayerStat, aligninstances, getPositionAwayFromOtherObjects +from World.Entities import PhysicalRound, Entity +import random +import logging +import pygame +from operator import attrgetter + +class BaseBaubleGame(BasicGame): + """ + Base Class for Creating Bauble Games which spawn Baubles of various colors/point values. + + Used by Hungry Hungry Baubles Basic Game and Advanced Bauble Hunt game. + """ + VALUE_TABLE = [] + + def __init__(self, cfgobj): + bb = cfgobj.getfloat("BaubleGame", "bauble_percent_blue") + yb = cfgobj.getfloat("BaubleGame", "bauble_percent_yellow") + rb = cfgobj.getfloat("BaubleGame", "bauble_percent_red") + BaseBaubleGame.VALUE_TABLE = [(bb, cfgobj.getint("BaubleGame", "bauble_points_blue")), (bb+yb, cfgobj.getint("BaubleGame", "bauble_points_yellow")), (bb+yb+rb, cfgobj.getint("BaubleGame", "bauble_points_red"))] + + super(BaseBaubleGame, self).__init__(cfgobj) + +class BaubleWrapper(GUIEntity): + def __init__(self, obj, world): + super(BaubleWrapper, self).__init__(obj, world) + self.surface = Cache().getImage("Games/Bauble" + str(obj.value)) + + def draw(self, surface, flags): + surface.blit(self.surface, intpos((self._worldobj.body.position[0] - 8, self._worldobj.body.position[1] - 8))) + + super(BaubleWrapper, self).draw(surface, flags) + +class Bauble(PhysicalRound): + WRAPPERCLASS = BaubleWrapper + """ + Baubles are small prizes worth different amounts of points + """ + def __init__(self, pos, value=1): + super(Bauble, self).__init__(8, 2000, pos) + self.shape.elasticity = 0.8 + self.health = PlayerStat(0) + + self.shape.group = 1 + + self.value = value + + def collide_start(self, otherobj): + return False + + def getExtraInfo(self, objData, player): + objData["VALUE"] = self.value + + @staticmethod + def spawn(world, cfg, pos=None): + if pos == None: + pos = getPositionAwayFromOtherObjects(world, cfg.getint("Bauble", "buffer_object"), cfg.getint("Bauble", "buffer_edge")) + + # Get value within tolerances + r = random.random() + v = 0 + for ent in BaseBaubleGame.VALUE_TABLE: + if r < ent[0]: + v = ent[1] + break + + b = Bauble(pos, v) + world.append(b) + return b diff --git a/SBA_Serv/Game/BaubleHunt.py b/SBA_Serv/Game/BaubleHunt.py index 427ef42..5c7390d 100644 --- a/SBA_Serv/Game/BaubleHunt.py +++ b/SBA_Serv/Game/BaubleHunt.py @@ -12,7 +12,7 @@ The full text of the license is available online: http://opensource.org/licenses/GPL-2.0 """ -from Game import BasicGame +from BaubleGame import * from Utils import CallbackTimer from World.Entities import Entity, PhysicalRound from World.WorldEntities import Ship @@ -27,15 +27,11 @@ import thread from operator import attrgetter -class BaubleHuntGame(BasicGame): +class BaubleHuntGame(BaseBaubleGame): VALUE_TABLE = [] def __init__(self, cfgobj): - bb = cfgobj.getfloat("BaubleHunt", "bauble_percent_blue") - yb = cfgobj.getfloat("BaubleHunt", "bauble_percent_yellow") - rb = cfgobj.getfloat("BaubleHunt", "bauble_percent_red") - self._mv = cfgobj.getint("BaubleHunt", "bauble_points_red") - BaubleHuntGame.VALUE_TABLE = [(bb, cfgobj.getint("BaubleHunt", "bauble_points_blue")), (bb+yb, cfgobj.getint("BaubleHunt", "bauble_points_yellow")), (bb+yb+rb, self._mv)] + self._mv = cfgobj.getint("BaubleGame", "bauble_points_red") self._respawn = cfgobj.getboolean("BaubleHunt", "respawn_bauble_on_collect") @@ -203,54 +199,6 @@ def round_start(self): super(BaubleHuntGame, self).round_start() - -class BaubleWrapper(GUIEntity): - def __init__(self, obj, world): - super(BaubleWrapper, self).__init__(obj, world) - self.surface = Cache().getImage("Games/Bauble" + str(obj.value)) - - def draw(self, surface, flags): - surface.blit(self.surface, intpos((self._worldobj.body.position[0] - 8, self._worldobj.body.position[1] - 8))) - - super(BaubleWrapper, self).draw(surface, flags) - -class Bauble(PhysicalRound): - WRAPPERCLASS = BaubleWrapper - """ - Baubles are small prizes worth different amounts of points - """ - def __init__(self, pos, value=1): - super(Bauble, self).__init__(8, 2000, pos) - self.shape.elasticity = 0.8 - self.health = PlayerStat(0) - - self.shape.group = 1 - - self.value = value - - def collide_start(self, otherobj): - return False - - def getExtraInfo(self, objData, player): - objData["VALUE"] = self.value - - @staticmethod - def spawn(world, cfg, pos=None): - if pos == None: - pos = getPositionAwayFromOtherObjects(world, cfg.getint("Bauble", "buffer_object"), cfg.getint("Bauble", "buffer_edge")) - - # Get value within tolerances - r = random.random() - v = 0 - for ent in BaubleHuntGame.VALUE_TABLE: - if r < ent[0]: - v = ent[1] - break - - b = Bauble(pos, v) - world.append(b) - return b - class OutpostWrapper(GUIEntity): def __init__(self, obj, world): super(OutpostWrapper, self).__init__(obj, world) diff --git a/SBA_Serv/Game/DiscoveryQuest.py b/SBA_Serv/Game/DiscoveryQuest.py index f4c5f80..66ce4b6 100644 --- a/SBA_Serv/Game/DiscoveryQuest.py +++ b/SBA_Serv/Game/DiscoveryQuest.py @@ -136,7 +136,7 @@ def game_get_extra_environment(self, player): env = super(DiscoveryQuestGame, self).game_get_extra_environment(player) if player.outpost != None: - env["OUTPOST"] = intpos(player.outpost.body.position) + env["POSITION"] = intpos(player.outpost.body.position) env["FAILED"] = player.failed env["MISSION"] = player.mission obj = player.object diff --git a/SBA_Serv/Game/Game.py b/SBA_Serv/Game/Game.py index f7f21d8..4bea37e 100644 --- a/SBA_Serv/Game/Game.py +++ b/SBA_Serv/Game/Game.py @@ -477,7 +477,7 @@ def player_update_score(self, player, amount): if player.score < 0: player.score = 0 - # TODO: should probably check if primary highest flag to see if we want to keep track of lowest or highest score here + # TODO: #118 should probably check if primary highest flag to see if we want to keep track of lowest or highest score here # update if this is a new personal best if player.score > player.bestscore: player.bestscore = player.score diff --git a/SBA_Serv/Game/HungryHungryBaubles.py b/SBA_Serv/Game/HungryHungryBaubles.py index bba5245..89be47a 100644 --- a/SBA_Serv/Game/HungryHungryBaubles.py +++ b/SBA_Serv/Game/HungryHungryBaubles.py @@ -12,11 +12,9 @@ The full text of the license is available online: http://opensource.org/licenses/GPL-2.0 """ -from Game import BasicGame +from BaubleGame import * from Utils import CallbackTimer -from World.Entities import PhysicalRound, Entity from World.WorldEntities import Ship -from GUI.ObjWrappers.GUIEntity import GUIEntity from World.WorldMath import intpos, friendly_type, PlayerStat, aligninstances, getPositionAwayFromOtherObjects from GUI.GraphicsCache import Cache from GUI.Helpers import debugfont @@ -24,23 +22,21 @@ import pygame from operator import attrgetter -class HungryHungryBaublesGame(BasicGame): +class HungryHungryBaublesGame(BaseBaubleGame): def __init__(self, cfgobj): - self.__points_blue = cfgobj.getint("HungryHungryBaubles", "bauble_points_blue") - self.__points_gold = cfgobj.getint("HungryHungryBaubles", "bauble_points_gold") + self.__points_blue = cfgobj.getint("BaubleGame", "bauble_points_blue") + self.__points_gold = cfgobj.getint("BaubleGame", "bauble_points_yellow") self.__points_extra = cfgobj.getint("HungryHungryBaubles", "bauble_points_extra") + self.__assign_specific_bauble = cfgobj.getboolean("HungryHungryBaubles", "assign_specific_bauble") self.__baubles = {} super(HungryHungryBaublesGame, self).__init__(cfgobj) - def game_get_info(self): - return {"GAMENAME": "HungryHungryBaubles"} - def player_added(self, player, reason): - if reason == BasicGame._ADD_REASON_START_: - self.__addBauble(player) # Add Home Base + if reason == BasicGame._ADD_REASON_START_ and self.__assign_specific_bauble: + self.__addBauble(player) # Add Golden Bauble super(HungryHungryBaublesGame, self).player_added(player, reason) @@ -65,13 +61,13 @@ def world_physics_pre_collision(self, obj1, obj2): def collectBaubles(self, ship, bauble): logging.info("Collected Baubles Ship #%d", ship.id) # collect own Bauble? - if bauble == self.__baubles[ship.player.netid]: + if self.__assign_specific_bauble and bauble == self.__baubles[ship.player.netid]: logging.info("Collected Own Bauble #%d", ship.id) self.player_update_score(ship.player, self.__points_extra) ship.player.sound = "COLLECT" # add new bauble self.__addBauble(ship.player, True) - elif bauble in self.__baubles.values(): + elif self.__assign_specific_bauble and bauble in self.__baubles.values(): logging.info("Collected Gold Bauble #%d", ship.id) # someone else's bauble for key, value in self.__baubles.iteritems(): @@ -94,52 +90,15 @@ def collectBaubles(self, ship, bauble): def game_get_extra_environment(self, player): env = super(HungryHungryBaublesGame, self).game_get_extra_environment(player) - env["POSITION"] = intpos(self.__baubles[player.netid].body.position) + if self.__assign_specific_bauble: + env["POSITION"] = intpos(self.__baubles[player.netid].body.position) return env def gui_draw_game_world_info(self, surface, flags, trackplayer): - for player in self.game_get_current_player_list(): - obj = player.object - if obj != None and self.__baubles.has_key(player.netid): - # draw line between player and Bauble - pygame.draw.line(surface, player.color, intpos(obj.body.position), intpos(self.__baubles[player.netid].body.position)) - -class BaubleWrapper(GUIEntity): - def __init__(self, obj, world): - super(BaubleWrapper, self).__init__(obj, world) - self.surface = Cache().getImage("Games/Bauble" + str(obj.value)) - - def draw(self, surface, flags): - # Check if Thrusting or Braking - surface.blit(self.surface, intpos((self._worldobj.body.position[0] - 8, self._worldobj.body.position[1] - 8))) - - super(BaubleWrapper, self).draw(surface, flags) - -class Bauble(PhysicalRound): - WRAPPERCLASS = BaubleWrapper - """ - Baubles are small prizes worth different amounts of points - """ - def __init__(self, pos, value=1): - super(Bauble, self).__init__(8, 2000, pos) - self.shape.elasticity = 0.8 - self.health = PlayerStat(0) - - self.shape.group = 1 - - self.value = value - - def collide_start(self, otherobj): - return False - - def getExtraInfo(self, objData, player): - objData["VALUE"] = self.value - - @staticmethod - def spawn(world, cfg, pos=None): - if pos == None: - pos = getPositionAwayFromOtherObjects(world, cfg.getint("Bauble", "buffer_object"), cfg.getint("Bauble", "buffer_edge")) - b = Bauble(pos, cfg.getint("HungryHungryBaubles", "bauble_points_blue")) - world.append(b) - return b + if self.__assign_specific_bauble: + for player in self.game_get_current_player_list(): + obj = player.object + if obj != None and self.__baubles.has_key(player.netid): + # draw line between player and Bauble + pygame.draw.line(surface, player.color, intpos(obj.body.position), intpos(self.__baubles[player.netid].body.position)) diff --git a/SBA_Serv/Game/__init__.py b/SBA_Serv/Game/__init__.py index 8aa0a57..60c92be 100644 --- a/SBA_Serv/Game/__init__.py +++ b/SBA_Serv/Game/__init__.py @@ -1 +1 @@ -__all__ = ["Game", "Players", "Utils", "Tournaments"] \ No newline at end of file +__all__ = ["Game", "BaubleGame", "Players", "Utils", "Tournaments"] \ No newline at end of file diff --git a/SBA_Serv/SBA_Serv.pyproj b/SBA_Serv/SBA_Serv.pyproj index e786d4f..8c28f92 100644 --- a/SBA_Serv/SBA_Serv.pyproj +++ b/SBA_Serv/SBA_Serv.pyproj @@ -33,6 +33,9 @@ + + Code + Code @@ -138,7 +141,7 @@ - + diff --git a/SBA_Serv/Tests/BaubleHuntTestCases.py b/SBA_Serv/Tests/BaubleHuntTestCases.py index d4cc9f0..5c1f8b6 100644 --- a/SBA_Serv/Tests/BaubleHuntTestCases.py +++ b/SBA_Serv/Tests/BaubleHuntTestCases.py @@ -119,7 +119,7 @@ def test_points_on_pickup(self): time.sleep(0.5) self.assertEqual(len(ship.player.carrying), 0, "Player didn't drop off baubles") - self.assertEqual(ship.player.score, self.cfg.getint("BaubleHunt", "bauble_points_blue") + self.cfg.getint("BaubleHunt", "bauble_points_yellow") + self.cfg.getint("BaubleHunt", "bauble_points_red"), "Player didn't earn bauble points") + self.assertEqual(ship.player.score, self.cfg.getint("BaubleGame", "bauble_points_blue") + self.cfg.getint("BaubleGame", "bauble_points_yellow") + self.cfg.getint("BaubleGame", "bauble_points_red"), "Player didn't earn bauble points") self.assertGreater(len(self.game.world), 7, "Baubles not respawned") diff --git a/SBA_Serv/Tests/HungryHungryBaublesTestCases.py b/SBA_Serv/Tests/HungryHungryBaublesTestCases.py index 4854dd7..64652e6 100644 --- a/SBA_Serv/Tests/HungryHungryBaublesTestCases.py +++ b/SBA_Serv/Tests/HungryHungryBaublesTestCases.py @@ -84,11 +84,11 @@ def test_points_on_pickup(self): time.sleep(5) - self.assertEqual(ship.player.score, self.cfg.getint("HungryHungryBaubles", "bauble_points_blue"), "Player didn't earn point") + self.assertEqual(ship.player.score, self.cfg.getint("BaubleGame", "bauble_points_blue"), "Player didn't earn point") time.sleep(6) - self.assertEqual(ship.player.score, self.cfg.getint("HungryHungryBaubles", "bauble_points_blue") + self.cfg.getint("HungryHungryBaubles", "bauble_points_gold"), "Player didn't earn point gold") + self.assertEqual(ship.player.score, self.cfg.getint("BaubleGame", "bauble_points_blue") + self.cfg.getint("BaubleGame", "bauble_points_yellow"), "Player didn't earn point gold") time.sleep(0.5) # move to golden bauble position @@ -97,7 +97,7 @@ def test_points_on_pickup(self): time.sleep(0.5) - self.assertEqual(ship.player.score, self.cfg.getint("HungryHungryBaubles", "bauble_points_blue") + self.cfg.getint("HungryHungryBaubles", "bauble_points_gold") * 2 + self.cfg.getint("HungryHungryBaubles", "bauble_points_extra"), "Player didn't earn golden bauble points") + self.assertEqual(ship.player.score, self.cfg.getint("BaubleGame", "bauble_points_blue") + self.cfg.getint("BaubleGame", "bauble_points_yellow") * 2 + self.cfg.getint("HungryHungryBaubles", "bauble_points_extra"), "Player didn't earn golden bauble points") time.sleep(0.5) diff --git a/SBA_Serv/Tests/test_baublehunt.cfg b/SBA_Serv/Tests/test_baublehunt.cfg index e02a6c3..38e974d 100644 --- a/SBA_Serv/Tests/test_baublehunt.cfg +++ b/SBA_Serv/Tests/test_baublehunt.cfg @@ -14,10 +14,7 @@ spawn_time_max = 6 game = BaubleHunt secondary_victory_attr = totalcollected -[BaubleHunt] -ship_cargo_size = 5 -respawn_bauble_on_collect = true - +[BaubleGame] bauble_percent_blue = 0.6 bauble_points_blue = 1 @@ -27,3 +24,6 @@ bauble_points_yellow = 3 bauble_percent_red = 0.1 bauble_points_red = 5 +[BaubleHunt] +ship_cargo_size = 5 +respawn_bauble_on_collect = true diff --git a/SBA_Serv/Tests/test_hungryhungrybaubles.cfg b/SBA_Serv/Tests/test_hungryhungrybaubles.cfg index 18f942a..07d9534 100644 --- a/SBA_Serv/Tests/test_hungryhungrybaubles.cfg +++ b/SBA_Serv/Tests/test_hungryhungrybaubles.cfg @@ -7,7 +7,16 @@ buffer_edge = 30 game = HungryHungryBaubles points_lost_on_death = 4 -[HungryHungryBaubles] +[BaubleGame] bauble_points_blue = 1 -bauble_points_gold = 3 +bauble_percent_blue = 0.8 + +bauble_points_yellow = 3 +bauble_percent_yellow = 0.2 + +bauble_points_red = 5 +bauble_percent_red = 0.0 + +[HungryHungryBaubles] bauble_points_extra = 2 +assign_specific_bauble = true diff --git a/SBA_Serv/Tests/test_hungryhungrybaubles2.cfg b/SBA_Serv/Tests/test_hungryhungrybaubles2.cfg index 6cd115b..720c4b9 100644 --- a/SBA_Serv/Tests/test_hungryhungrybaubles2.cfg +++ b/SBA_Serv/Tests/test_hungryhungrybaubles2.cfg @@ -14,7 +14,16 @@ spawn_time_max = 5 game = HungryHungryBaubles points_lost_on_death = 4 -[HungryHungryBaubles] +[BaubleGame] bauble_points_blue = 1 -bauble_points_gold = 3 +bauble_percent_blue = 0.8 + +bauble_points_yellow = 3 +bauble_percent_yellow = 0.2 + +bauble_points_red = 5 +bauble_percent_red = 0.0 + +[HungryHungryBaubles] bauble_points_extra = 2 +assign_specific_bauble = true diff --git a/SBA_Serv/game_hungryhungrybaubles.cfg b/SBA_Serv/basicgame_hungryhungrybaubles.cfg similarity index 69% rename from SBA_Serv/game_hungryhungrybaubles.cfg rename to SBA_Serv/basicgame_hungryhungrybaubles.cfg index 1f1f942..1593a80 100644 --- a/SBA_Serv/game_hungryhungrybaubles.cfg +++ b/SBA_Serv/basicgame_hungryhungrybaubles.cfg @@ -18,7 +18,16 @@ spawn_time_max = 25 game = HungryHungryBaubles points_lost_on_death = 4 -[HungryHungryBaubles] +[BaubleGame] bauble_points_blue = 1 -bauble_points_gold = 3 +bauble_percent_blue = 0.8 + +bauble_points_yellow = 3 +bauble_percent_yellow = 0.2 + +bauble_points_red = 5 +bauble_percent_red = 0.0 + +[HungryHungryBaubles] bauble_points_extra = 2 +assign_specific_bauble = true diff --git a/SBA_Serv/buildnum b/SBA_Serv/buildnum index e9fa9e7..03a524d 100644 --- a/SBA_Serv/buildnum +++ b/SBA_Serv/buildnum @@ -1 +1 @@ -1114 \ No newline at end of file +1115 \ No newline at end of file diff --git a/SBA_Serv/game_baublehunt.cfg b/SBA_Serv/game_baublehunt.cfg index 3906241..9a7926a 100644 --- a/SBA_Serv/game_baublehunt.cfg +++ b/SBA_Serv/game_baublehunt.cfg @@ -28,16 +28,16 @@ spawn_time_max = 15 game = BaubleHunt secondary_victory_attr = totalcollected -[BaubleHunt] -ship_cargo_size = 5 -respawn_bauble_on_collect = true - -bauble_percent_blue = 0.6 +[BaubleGame] bauble_points_blue = 1 +bauble_percent_blue = 0.6 -bauble_percent_yellow = 0.3 bauble_points_yellow = 3 +bauble_percent_yellow = 0.2 -bauble_percent_red = 0.1 bauble_points_red = 5 +bauble_percent_red = 0.2 +[BaubleHunt] +ship_cargo_size = 5 +respawn_bauble_on_collect = true diff --git a/changelog.md b/changelog.md index 5f41462..caba54c 100644 --- a/changelog.md +++ b/changelog.md @@ -14,10 +14,16 @@ v1.2 : Planned - May 2016 [Season 5] * Added **getClosestMappedPoint** for world bounds assistance * Added ability for client to get info on ship's running commands **getCommandQueue** in the environment *getShipStatus*. * Command Queue and Current Energy Properties are now only available to its own ship (can't be seen with radar). -* **Removed SelfDestructCommand** +* Added new *reset_timer* option to Find the Middle Basic Game * Added option for Torpedoes to be effected by gravity * Split 'explodable' from 'gravitable' for Entities, two separate object flags now. * Separated option for 'showip' in Application settings to decouple from showing statistics, no longer always show IP in Debug mode. +* **Breaking Changes:** + * Made **Hungry Hungry Baubles** a Basic Game by creating a *getObjectiveLocation()* method on BasicGameInfo (instead of *getGoldenBaublePosition()*). This is now also used by **Bauble Hunt** and **Discovery Quest** instead of *getHomeBasePosition()*. + * Hungry Hungry Baubles has new options for configuration (default is similar to previous incarnation). + * Hungry Hungry Baubles and Bauble Hunt now share new *[BaubleGame]* point/percentage spawning parameters. + * RotateCommand/Orientation Related Client code now uses **int** vs. **double**. + * **Removed SelfDestructCommand** v1.1.0.1111 : 04/21/2016 [Season 4 Release] - Discovery Quest ---- diff --git a/doc/games/basic.md b/doc/games/basic.md index edde9c4..ee32ebb 100644 --- a/doc/games/basic.md +++ b/doc/games/basic.md @@ -8,6 +8,7 @@ outline: - { url: "survivor.html", title: "Survivor" } - { url: "asteroidminer.html", title: "Asteroid Miner" } - { url: "combatexercise.html", title: "Combat Exercise" } + - { url: "hungryhungrybaubles.html", title: "Hungry Hungry Baubles" } --- Basic Games @@ -16,6 +17,6 @@ Basic games can be played with the default implementation of BasicSpaceship with All basic games use the [BasicGameInfo](http://mikeware.github.io/SpaceBattleArena/client/java_doc/ihs/apcs/spacebattle/BasicGameInfo.html) object provided in the [BasicSpaceship](http://mikeware.github.io/SpaceBattleArena/client/java_doc/ihs/apcs/spacebattle/BasicSpaceship.html) abstract class. -This object contains common elements like a player's score, best score, number of deaths, or information about the game itself such as the highest score, the time left in the round, or the total time of the round. +This object contains common elements like a player's score, best score, number of deaths, or information about the game itself such as the highest score, the time left in the round, the total time of the round, or the location of an objective. Basic games also have a lot of configuration available through the [game configuration section](../server/config.html#game). diff --git a/doc/games/baublehunt.md b/doc/games/baublehunt.md index d4060b5..175d7f9 100644 --- a/doc/games/baublehunt.md +++ b/doc/games/baublehunt.md @@ -15,7 +15,7 @@ Bauble Hunt ----------- **Bauble Hunt** is a more complex version of the [Hungry Hungry Baubles](hungryhungrybaubles.html) game. -Every player has a **home base** and baubles *only count* towards your score once they have been collected and returned to your Home Base. +Every player has a **home base** (locatable with *getObjectiveLocation()* and baubles *only count* towards your score once they have been collected and returned to your Home Base. You may store 5 Baubles on your ship at most. @@ -34,22 +34,17 @@ Control Bauble spawning behavior by using the standard [Spawn Manager](../server Configuration ----------- -###ship_cargo_size = int -The maximum number of baubles each ship can carry. - -###respawn_bauble_on_collect = boolean -Should a new bauble be spawned every time one is collected? - +##[BaubleGame] ###bauble_percent_blue = float The percentage of baubles which should generate as blue from [0.0-1.0]. The total of **bauble_percent_blue**, **bauble_percent_yellow**, and **bauble_percent_red** should equal 1.0. ###bauble_points_blue = int How many points is the standard bauble worth. **Note:** *modifying the point values requires that adequate images be placed in the GUI/Graphics/Games folder to represent that value.* -###bauble_percent_gold = float +###bauble_percent_yellow = float The percentage of baubles which should generate as gold from [0.0-1.0]. The total of **bauble_percent_blue**, **bauble_percent_yellow**, and **bauble_percent_red** should equal 1.0. -###bauble_points_gold = int +###bauble_points_yellow = int How many points is a golden bauble worth. ###bauble_percent_red = float @@ -57,3 +52,13 @@ The percentage of baubles which should generate as red from [0.0-1.0]. The tota ###bauble_points_red = int How many points is a red bauble worth. + + +##[BaubleHunt] + +###ship_cargo_size = int +The maximum number of baubles each ship can carry. + +###respawn_bauble_on_collect = boolean +Should a new bauble be spawned every time one is collected? + diff --git a/doc/games/discoveryquest.md b/doc/games/discoveryquest.md index 4b77ddd..67e2679 100644 --- a/doc/games/discoveryquest.md +++ b/doc/games/discoveryquest.md @@ -15,7 +15,7 @@ Discovery Quest ----------- **Discovery Quest** is an exploration game where players must navigate space in order to 'scan' objects and accumulate points. They establish a research **Outpost** which can also provide them with specific missions for additional points. -Players must establish an **Outpost** by scanning it before any points will count towards their placement within the game. Any points earned prior to establishing an Outpost will be banked and awarded when an Outpost is first established. (Multiple players may establish and share the same Outpost.) +Players must establish an **Outpost** by scanning it before any points will count towards their placement within the game. Any points earned prior to establishing an Outpost will be banked and awarded when an Outpost is first established. (Multiple players may establish and share the same Outpost.) An established Outpost's location can be later retrieved with the *getObjectiveLocation()* method of the environment's getGameInfo(). *Scanning* is a specific command that must be used within 150 pixels of an object and must be directed towards a specific object by using its ID number. Scanning is **not** the same as Radar. The object being scanned must remain in range for the entire duration of the scan. diff --git a/doc/games/hungryhungrybaubles.md b/doc/games/hungryhungrybaubles.md index 475208b..7ec20b2 100644 --- a/doc/games/hungryhungrybaubles.md +++ b/doc/games/hungryhungrybaubles.md @@ -2,26 +2,29 @@ title: Hungry Hungry Baubles nav: - { url: "index.html", title: "Competitions" } + - { url: "basic.html", title: "Basic Games" } outline-header: Outline outline: - { url: "#overview", title: "Overview" } - { url: "#config", title: "Configuration" } --- -Hungry Hungry Baubles +Hungry Hungry Baubles [Basic Game] ============= Overview ----------- -**Hungry Hungry Baubles** is a game where you must try and collect as many baubles as you can before time runs out. +**Hungry Hungry Baubles** is a basic game where you must try and collect as many baubles as you can before time runs out. -Every bauble is worth 1 point. +Every bauble is worth at least 1 point. -However, every player is also provided the location of a **golden** bauble. If they collect it they will earn **5 points**. +However, every player is also provided the location of a **golden** bauble (added specifically for them outside of spawning parameters). If they collect it they will earn **5 points** (3 + 2 additional, if enabled). If they happen to collect someone else's golden bauble it's only worth 3 points. +Red Baubles are worth 5 points (if enabled, see **bauble_percent_red**). + The default configuration also specifies that you lose 4 points when dying. See [[Game] Properties](../server/config.html#game). Control Bauble spawning behavior by using the standard [Spawn Manager](../server/config.html#spawnmanager) properties. @@ -29,11 +32,30 @@ Control Bauble spawning behavior by using the standard [Spawn Manager](../server Configuration ----------- +##[BaubleGame] + ###bauble_points_blue = int How many points a standard blue bauble is worth. **Note:** *modifying the point values requires that adequate images be placed in the GUI/Graphics/Games folder to represent that value.* -###bauble_points_gold = int +###bauble_points_yellow = int How many points a golden bauble worth. +###bauble_points_red = int +How many points is a red bauble worth. + +###bauble_percent_blue = float +The percentage of baubles which should generate as blue from [0.0-1.0]. The total of **bauble_percent_blue**, **bauble_percent_yellow**, and **bauble_percent_red** should equal 1.0. + +###bauble_percent_yellow = float +The percentage of baubles which should generate as gold from [0.0-1.0]. The total of **bauble_percent_blue**, **bauble_percent_yellow**, and **bauble_percent_red** should equal 1.0. + +###bauble_percent_red = float +The percentage of baubles which should generate as red from [0.0-1.0]. The total of **bauble_percent_blue**, **bauble_percent_yellow**, and **bauble_percent_red** should equal 1.0. + +## [HungryHungryBaubles] + +###assign_specific_bauble = boolean +Assign each player a golden bauble to retrieve given through *getObjectiveLocation()* in the environment's *getGameInfo()*. Defaults to true. + ###bauble_points_extra = int -How many extra points is your specific golden bauble worth to you (doesn't require special image). +How many extra points is your specific golden bauble worth to you (doesn't require special image). Only if **assign_specific_bauble** is turned on. diff --git a/doc/index.md b/doc/index.md index cb55d31..0c2d9bf 100644 --- a/doc/index.md +++ b/doc/index.md @@ -58,7 +58,7 @@ Documentation * [Survivor](games/survivor.html) * [Asteroid Miner](games/asteroidminer.html) * [Combat Exercise](games/combatexercise.html) - * [Hungry Hungry Baubles](games/hungryhungrybaubles.html) + * [Hungry Hungry Baubles](games/hungryhungrybaubles.html) * [Bauble Hunt](games/baublehunt.html) * [King of the Bubble](games/kingofthebubble.html) * [King of Space (Variant)](games/kingofthebubble.html#kos) diff --git a/java_client_src/src/ihs/apcs/spacebattle/BasicGameInfo.java b/java_client_src/src/ihs/apcs/spacebattle/BasicGameInfo.java index fb3e84a..6edcbe9 100644 --- a/java_client_src/src/ihs/apcs/spacebattle/BasicGameInfo.java +++ b/java_client_src/src/ihs/apcs/spacebattle/BasicGameInfo.java @@ -21,6 +21,9 @@ public class BasicGameInfo { private double HIGHSCORE; private double TIMELEFT; private double ROUNDTIME; + + // Possible Objective Location + private double[] POSITION; /** * Gets your current score. @@ -66,7 +69,13 @@ public class BasicGameInfo { * Will be 0 if there is currently no time limit. * @return total length of time for the current game's round */ - public double getTotalRoundTime() { return ROUNDTIME; } + public double getTotalRoundTime() { return ROUNDTIME; } + + /** + * Gets a potential position of an assigned game location (read game rules for details). + * @return the objective's position + */ + public Point getObjectiveLocation() { return POSITION != null ? new Point(POSITION) : null; } @Override public String toString() { diff --git a/java_client_src/src/ihs/apcs/spacebattle/games/BaubleHuntGameInfo.java b/java_client_src/src/ihs/apcs/spacebattle/games/BaubleHuntGameInfo.java index 4c982c5..f09541b 100644 --- a/java_client_src/src/ihs/apcs/spacebattle/games/BaubleHuntGameInfo.java +++ b/java_client_src/src/ihs/apcs/spacebattle/games/BaubleHuntGameInfo.java @@ -22,18 +22,11 @@ * @version 1.0 */ public class BaubleHuntGameInfo extends BasicGameInfo { - private double[] POSITION; private double[][] BAUBLES; private int COLLECTED; private int STORED; private int STOREDVALUE; - /** - * Gets the position of your home base outpost. - * @return the position of your home base outpost - */ - public Point getHomeBasePosition() { return new Point(POSITION); } - /** * Gets a list of positions where there are high-value baubles. Not all * bauble positions are returned, but each position in the list @@ -68,6 +61,6 @@ public List getBaublePositions() { @Override public String toString() { - return String.format("{Target: %s; Score: %f; Deaths: %d; High Score: %f}", getHomeBasePosition(), getScore(), getNumDeaths(), getHighScore()); + return String.format("{Target: %s; Score: %f; Deaths: %d; High Score: %f}", getObjectiveLocation(), getScore(), getNumDeaths(), getHighScore()); } } diff --git a/java_client_src/src/ihs/apcs/spacebattle/games/DiscoveryQuestGameInfo.java b/java_client_src/src/ihs/apcs/spacebattle/games/DiscoveryQuestGameInfo.java index 0ac80e7..c5da022 100644 --- a/java_client_src/src/ihs/apcs/spacebattle/games/DiscoveryQuestGameInfo.java +++ b/java_client_src/src/ihs/apcs/spacebattle/games/DiscoveryQuestGameInfo.java @@ -1,7 +1,6 @@ package ihs.apcs.spacebattle.games; import ihs.apcs.spacebattle.BasicGameInfo; -import ihs.apcs.spacebattle.Point; import ihs.apcs.spacebattle.commands.ScanCommand; import java.util.*; @@ -32,19 +31,9 @@ public class DiscoveryQuestGameInfo extends BasicGameInfo { private String[] MISSION; private boolean FAILED; - private double[] OUTPOST; private int[] CURIDS; private int[] SUCIDS; - - /** - * Gets the position of your home base outpost. - * - *

This value will be null initially, until your first Outpost is Scanned. - * - * @return the position of your home base outpost - */ - public Point getHomeBasePosition() { return OUTPOST != null ? new Point(OUTPOST) : null; } - + /** * Indicates if the current missions is still a success or not. * This value will be true at the start of the game. @@ -85,6 +74,6 @@ public class DiscoveryQuestGameInfo extends BasicGameInfo { @Override public String toString() { - return String.format("{Mission: %s; Outpost: %s; Score: %f; Deaths: %d; High Score: %f}", Arrays.toString(getMissionLeft()), getHomeBasePosition(), getScore(), getNumDeaths(), getHighScore()); + return String.format("{Mission: %s; Outpost: %s; Score: %f; Deaths: %d; High Score: %f}", Arrays.toString(getMissionLeft()), getObjectiveLocation(), getScore(), getNumDeaths(), getHighScore()); } } diff --git a/java_client_src/src/ihs/apcs/spacebattle/games/HungryHungryBaublesGameInfo.java b/java_client_src/src/ihs/apcs/spacebattle/games/HungryHungryBaublesGameInfo.java deleted file mode 100644 index f0086fe..0000000 --- a/java_client_src/src/ihs/apcs/spacebattle/games/HungryHungryBaublesGameInfo.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * - */ -package ihs.apcs.spacebattle.games; - -import ihs.apcs.spacebattle.BasicGameInfo; -import ihs.apcs.spacebattle.Point; - -/** - * Hungry Hungry Baubles is a game where you must collect Baubles within the world for points. - *

- * There are regular Baubles and 'Golden' Baubles. - *

- * Regular Baubles are worth 1 point.

- * Golden Baubles are worth 3 points. - *

- * You are assigned a specific Golden Bauble, if you collect it, it's worth an additional 2 points. You will be then assigned another Golden Bauble to collect. - * - * @author Michael A. Hawker - * - * @since 0.75 - * @version 1.0 - */ -public class HungryHungryBaublesGameInfo extends BasicGameInfo { - private double[] POSITION; - - /** - * Gets the position of your assigned golden Bauble. - * @return the position of your golden Bauble - */ - public Point getGoldenBaublePosition() { return new Point(POSITION); } -} diff --git a/java_client_src/src/ihs/apcs/spacebattle/networking/MwnpMessage.java b/java_client_src/src/ihs/apcs/spacebattle/networking/MwnpMessage.java index 506c3b6..c971f9e 100644 --- a/java_client_src/src/ihs/apcs/spacebattle/networking/MwnpMessage.java +++ b/java_client_src/src/ihs/apcs/spacebattle/networking/MwnpMessage.java @@ -33,9 +33,6 @@ public static void RegisterGameType(String gameName) { switch (gameName) { - case "HungryHungryBaubles": - cmdDataTypes.put("\"ENV\"", new TypeToken>() {}.getType()); - break; case "BaubleHunt": cmdDataTypes.put("\"ENV\"", new TypeToken>() {}.getType()); break;