fill out creatures file and implement loadCreatures
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
###############################################
|
||||||
|
Prompt to Kiro AI (Default):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Response:
|
||||||
|
|
||||||
|
|
||||||
|
###############################################
|
||||||
+11
-11
@@ -1,11 +1,11 @@
|
|||||||
name description price sprite-file difficulty length weight
|
name description price sprite-file difficulty length (in) weight (lbs)
|
||||||
The Rainbow Fish
|
The Rainbow Fish The friendliest fish from our childhood 120 rainbow-fish.png 90 8.2 1.4
|
||||||
Pufferfish
|
Pufferfish yeeeeowwwch!! 56 pufferfish.png 50 6.8 3.1
|
||||||
Turtle
|
Turtle "Give me some fin. Noggin. Duuuude." - Crush, Finding Nemo 30 turtle.png 40 72 180
|
||||||
Shrimp
|
Shrimp Yeah, I'm a little small. Whaddaboutit? 18 shrimp.png 20 0.7 0.2
|
||||||
Lobster
|
Lobster ROCK LOBSTERRRR OOOO OOOH 82 lobster.png 80 13.3 4.5
|
||||||
Aubrey Fish Requested by the artist, my girlfriend.
|
Aubrey Fish Requested by the artist, my girlfriend. 65 aubrey-fish.png 60 4.3 1.9
|
||||||
Hammerhead Shark
|
Hammerhead Shark Great for building a shed. Not so great in the ocean 150 hammerhead.png 100 120 560
|
||||||
Koi Fish
|
Koi Fish WHO'S HOUSE?? MUDGE HOUSE!! 26 mudge-fish.png 20 10.4 1.6
|
||||||
One Fish Two Fish Red Fish Blue Fish Yes, you caught a book.
|
One Fish Two Fish Red Fish Blue Fish Yes, you caught a book. 66 book.png 70 8.5 2
|
||||||
Bone Fish
|
Bone Fish He must have needed saltwater... 12 bone-fish.png 10 16.1 0.8
|
||||||
|
Can't render this file because it contains an unexpected character in line 4 and column 43.
|
@@ -19,14 +19,29 @@ from cmu_graphics import *
|
|||||||
# the data source (TSV path, save path) can change without touching gameplay.
|
# the data source (TSV path, save path) can change without touching gameplay.
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
def loadCreatures(path):
|
def loadCreatures(path="creatures.tsv"):
|
||||||
# Read creatures.tsv (tab-separated) and parse it into a usable structure.
|
# Read creatures.tsv (tab-separated) and parse it into a usable structure.
|
||||||
# Suggested return: a list of dicts, one per creature, with keys matching
|
# Suggested return: a list of dicts, one per creature, with keys matching
|
||||||
# the header row: name, description, price, sprite-file, difficulty,
|
# the header row: name, description, price, sprite-file, difficulty,
|
||||||
# length, weight. Convert numeric columns (price, difficulty, length,
|
# length, weight. Convert numeric columns (price, difficulty, length,
|
||||||
# weight) from strings to int/float here; leave missing fields as sensible
|
# weight) from strings to int/float here; leave missing fields as sensible
|
||||||
# defaults so partially-filled rows (like the current TSV) don't crash.
|
# defaults so partially-filled rows (like the current TSV) don't crash.
|
||||||
pass
|
creatures = []
|
||||||
|
with open(path) as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
for line in lines[1:]: #ignore header
|
||||||
|
data = line.split("\t")
|
||||||
|
creatures.append({
|
||||||
|
"name": data[0],
|
||||||
|
"description": data[1],
|
||||||
|
"price": float(data[2]),
|
||||||
|
"sprite-file": data[3],
|
||||||
|
"difficulty": int(data[4]),
|
||||||
|
"length": float(data[5]), #inches
|
||||||
|
"weight": float(data[6]) #pounds
|
||||||
|
})
|
||||||
|
|
||||||
|
return creatures
|
||||||
|
|
||||||
|
|
||||||
def loadSave(path):
|
def loadSave(path):
|
||||||
|
|||||||
Reference in New Issue
Block a user