Skip to content

Commit 94c6dca

Browse files
committed
Fixes #140 Extra Discovery Quest Options
Can not require a home base now Can also turn off missions
1 parent aad9dae commit 94c6dca

File tree

3 files changed

+38
-20
lines changed

3 files changed

+38
-20
lines changed

SBA_Serv/Game/DiscoveryQuest.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ def __init__(self, cfgobj):
4848

4949
super(DiscoveryQuestGame, self).__init__(cfgobj)
5050

51+
self.mustbase = cfgobj.getboolean("DiscoveryQuest", "establish_homebase")
52+
self.usemissions = cfgobj.getboolean("DiscoveryQuest", "missions")
5153
self._missions = cfgobj.get("DiscoveryQuest", "mission_objectives").split(",")
5254
self.scantime = cfgobj.getfloat("DiscoveryQuest", "scan_time")
5355
self.scanrange = cfgobj.getint("DiscoveryQuest", "scan_range")
@@ -58,22 +60,23 @@ def game_get_info(self):
5860
return {"GAMENAME": "DiscoveryQuest"}
5961

6062
def player_reset_mission(self, player):
61-
# get a number of missions for each thing
62-
player.mission = []
63-
player.scanned = []
64-
player.failed = False
65-
for i in xrange(cfg_rand_min_max(self.cfg, "DiscoveryQuest", "mission_num")):
66-
player.mission.append(random.choice(self._missions)) # TODO: validate that this player can still scan those types of objects
63+
if self.usemissions:
64+
# get a number of missions for each thing
65+
player.mission = []
66+
player.scanned = []
67+
player.failed = False
68+
for i in xrange(cfg_rand_min_max(self.cfg, "DiscoveryQuest", "mission_num")):
69+
player.mission.append(random.choice(self._missions)) # TODO: validate that this player can still scan those types of objects
6770

6871
def player_added(self, player, reason):
6972
if reason == BasicGame._ADD_REASON_REGISTER_:
70-
player.buffervalue = 0
71-
player.outpost = None
72-
player.lastids = []
73+
player.buffervalue = 0 # stored points before scanning first output, if outpost is required.
74+
player.outpost = None # home base obj
75+
player.lastids = [] # last ids scanned
7376

74-
player.mission = []
75-
player.scanned = []
76-
player.failed = True
77+
player.mission = [] # List of strings of items to scan
78+
player.scanned = [] # ids scanned by player
79+
player.failed = True # whether current mission has failed, starts as true as no mission to start
7780

7881
return super(DiscoveryQuestGame, self).player_added(player, reason)
7982

@@ -129,6 +132,9 @@ def world_add_remove_object(self, wobj, added):
129132
opt = "points_" + friendly_type(wobj).lower()
130133
if self.cfg.has_option("DiscoveryQuest", opt):
131134
wobj.value = self.cfg.getint("DiscoveryQuest", opt)
135+
else:
136+
#guard
137+
wobj.value = 0
132138

133139
return super(DiscoveryQuestGame, self).world_add_remove_object(wobj, added)
134140

@@ -210,7 +216,7 @@ def dq_finished_scan(self, ship, obj, success):
210216
ship.player.buffervalue = 0
211217
ship.player.sound = "SUCCESS"
212218

213-
if not ship.player.failed and len(ship.player.mission) == 0: # completed mission exactly
219+
if self.usemissions and not ship.player.failed and len(ship.player.mission) == 0: # completed mission exactly
214220
points = 0
215221
# tally points of scanned objects
216222
for obj in ship.player.scanned:
@@ -233,7 +239,7 @@ def dq_finished_scan(self, ship, obj, success):
233239
# update scores
234240
obj.scanned_by.append(ship.player)
235241
ship.player.sound = "SUCCESS"
236-
if ship.player.outpost != None:
242+
if ship.player.outpost != None or not self.mustbase: # or we don't require bases for points
237243
ship.player.update_score(obj.value)
238244
else: #haven't found outpost, need to buffer points
239245
ship.player.buffervalue += obj.value
@@ -245,8 +251,9 @@ def gui_draw_game_world_info(self, surface, flags, trackplayer):
245251
if obj != None:
246252
bp = intpos(obj.body.position)
247253
wrapcircle(surface, (0, 255, 255), bp, self.scanrange, self.world.size, 1) # Scan Range
248-
text = debugfont().render("%s [%s]" % (repr(player.mission), player.failed), False, (0, 255, 255))
249-
surface.blit(text, (bp[0]-text.get_width()/2, bp[1] - 6))
254+
if self.usemissions:
255+
text = debugfont().render("%s [%s]" % (repr(player.mission), player.failed), False, (0, 255, 255))
256+
surface.blit(text, (bp[0]-text.get_width()/2, bp[1] - 6))
250257

251258
if trackplayer != None:
252259
curs = []

SBA_Serv/game_discoveryquest.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ secondary_victory_attr = buffervalue
4747
secondary_victory_highest = true
4848

4949
[DiscoveryQuest]
50+
establish_homebase = true
5051
scan_time = 3.5
5152
scan_range = 150
5253
ship_spawn_dist = 105
5354
disable_warp_in_nebula = true
55+
missions = true
5456
mission_objectives = Asteroid,Planet,BlackHole,Nebula,Star,Outpost,WormHole
5557
mission_num_min = 1
5658
mission_num_max = 3

doc/games/discoveryquest.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,22 @@ Discovery Quest
1515
-----------
1616
**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.
1717

18-
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().
18+
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(). *This can be turned off with configuration such that any objects scanned will receive points.*
1919

2020
*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.
2121

22-
A **Mission** dictates which objects a ship should go scan. If a ship goes and scans ONLY those things, bonus points will be awarded when they return to their outpost and Scan it again. Scanning your Outpost will always give you a new mission.
22+
A **Mission** dictates which objects a ship should go scan. If a ship goes and scans ***ONLY*** those things, bonus points will be awarded when they return to their outpost and Scan it again. Scanning your Outpost will always give you a new mission. **Note:** the first Outpost you scan becomes your base and is the only Outpost you can receive and complete missions from. (Other Outposts may still be scanned for points or mission objectives.)
2323

2424
Your Ship being destroyed clears/fails your mission, so you must return to your established Outpost if you want a new one.
2525

26-
Discovery Quest prevents warping out of Nebulas.
26+
**NOTE: Discovery Quest prevents warping out of Nebulas, unless turned off in configuration.**
2727

2828

2929
<a name="config"></a>Configuration
3030
-----------
31+
###establish_homebase = boolean
32+
Whether or not the player must scan an Outpost first in order to start banking points. When off, all points scanned will count, Outposts can still be scanned for points and bonus missions if missions are enabled (see below).
33+
3134
###scan_time = float
3235
Amount of time required to complete a successful scan in seconds. (3.5 default)
3336

@@ -40,6 +43,9 @@ Maximum distance a ship will spawn away from an Outpost.
4043
###disable_warp_in_nebula = boolean
4144
Set to prevent players from Warping out of Nebulas. (true default)
4245

46+
###missions = boolean
47+
Whether or not missions can be obtained from scanning outposts.
48+
4349
###mission_objectives = string
4450
Comma separated list of object types which can appear within Missions.
4551

@@ -77,4 +83,7 @@ Number of points a Dragon is worth when successfully scanned. (6 default)
7783
Number of points a Worm Hole is worth when successfully scanned. (2 default)
7884

7985
###points_ship = int
80-
Number of points another Ship is worth when successfully scanned. (4 default)
86+
Number of points another Ship is worth when successfully scanned. (4 default)
87+
88+
###points_spacemine = int
89+
Number of points a Space Mine is worth when successfully scanned. (8 default)

0 commit comments

Comments
 (0)