Skip to content
Snippets Groups Projects
Commit d2f5ced6 authored by Ryan Tresman's avatar Ryan Tresman
Browse files
parents 58b360a9 037af001
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,7 @@ You suddenly wake up in an ancient abandoned manner house. Every window boarded,
Matthew Aked, Ahmed El Ghazali, Thomas Glasper, Joshua Lewis, Evan Morgan, Haroon Raza, Ryan Tresman and Harry Wyatt.
## To Do
- Upgrade items to classes and randomly generate items in each room - Harry Wyatt - in progress
- Upgrade items to classes and randomly generate items in each room - Harry Wyatt - done
- Convert player to class - Thomas Glasper - done
- Equipping and unequipping items - Thomas Glasper - done
- Inventory menu (including inspecting items) - Thomas Glasper - done
......
......@@ -5,6 +5,7 @@ from player import *
from items import *
from gameparser import *
from enemies import *
from item_dist import *
import random
def display_inventory():
......@@ -477,6 +478,9 @@ def move(exits, direction):
# This is the entry point of our program
def main():
# Generate random items in each room before we start the game
populate_rooms()
print("You suddenly wake up in an ancient abandoned manner house. Every window boarded, every door to the real world locked...")
print("The old house finds itself inhabited by a plethora of strange monsters, of which many seem violent. It is up to you...")
print("to trek forward and find a way out with what little you have - avoiding death as if it were around every corner.")
......
......@@ -3,6 +3,8 @@ This file is designed to distribute items around the map, so the player can have
each time they play the game
'''
from map import *
import random
import copy
# HINT: Use ALL_ROOMS string keyword in spawnable to allow the item to spawn in all rooms at that base percentage
......@@ -209,12 +211,42 @@ spawnable_items = {
}
def evaluate_spawn(obj, room, probability):
'''
evaluate_spawn will see if an object should be copied into a room based on the
probably of the item spawning in there. If it should spawn in there,
it performs this action
'''
will_spawn = random.random() < probability
if will_spawn is True:
new_item = copy.deepcopy(obj)
room.items.append(new_item)
def populate_rooms():
'''
This function is designed to populate the rooms
This function is designed to populate the rooms with items so that the user
can experience a unique experience
'''
global rooms
for room in rooms:
pass
'''
In the final implementation of this code, a file will be read with a pickled
version of this variable.
'''
global spawnable_items
for category in spawnable_items:
for item in spawnable_items[category]:
# Check what rooms this item can spawn in
for room in item.spawnable:
# We can have either Room or the keyword ALL_ROOMS
if type(room) == Room:
evaluate_spawn(item, room, item.spawnable[room])
else:
if room == "ALL_ROOMS":
for r in rooms:
# We don't wanna evaluate the spawn rate twice if there's an override
if not rooms[r] in item.spawnable:
evaluate_spawn(item, rooms[r], item.spawnable[room])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment