added Kinggotchi, multiple Villages in Kingdom
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# The lenght of one game cycle in milliseconds
|
||||
ticklenght = 0.05
|
||||
ticklenght = 0.005
|
||||
# Number of Tamagotchis to be created at the start of the simulation
|
||||
startnr = 50
|
||||
startnr = 100
|
||||
# The amount of points a Tamagotchi loses per tick
|
||||
decayaspeed = 1
|
||||
# If the hunger stat falls below this level Tamagotchis can be fed
|
||||
|
||||
@@ -16,5 +16,28 @@ class Kinggotchi:
|
||||
self.myvillages.append(mayor)
|
||||
|
||||
def show_kingdom(self):
|
||||
result = 'I am Kinggotchi '+str(self.name)+'.\nThese are the '+str(len(self.myvillages))+' Villages in my Kingdom:\n'
|
||||
result = 'I am Kinggotchi '+str(self.name)+'.\nIn my Kingdom live '+str(self.all_tamagotchis())+' Tamagotichs.\nIn my Kingdom '+str(self.all_dead())+' Tamagotchis have died so far.\n\nThese are the '+str(len(self.myvillages))+' Villages in my Kingdom:\n'
|
||||
|
||||
for n in self.myvillages:
|
||||
result += '-------------------------------------------------------------------------------\n'
|
||||
result += n.give_overview()
|
||||
|
||||
return result
|
||||
|
||||
def step(self):
|
||||
for n in self.myvillages:
|
||||
n.step()
|
||||
|
||||
def all_tamagotchis(self):
|
||||
result = 0
|
||||
for n in self.myvillages:
|
||||
result += len(n.mygotchis)
|
||||
return result
|
||||
|
||||
def all_dead(self):
|
||||
result = 0
|
||||
for n in self.myvillages:
|
||||
result += n.graveyard
|
||||
return result
|
||||
|
||||
|
||||
19
test.py
19
test.py
@@ -1,20 +1,24 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
from mayorgotchi import Mayorgotchi
|
||||
from kinggotchi import Kinggotchi
|
||||
from util import Util
|
||||
from config import *
|
||||
import time
|
||||
import curses
|
||||
|
||||
# Temporary test section
|
||||
|
||||
list = []
|
||||
ticks = 0
|
||||
for n in range(0,startnr):
|
||||
list.append(Util().make_Tamagotchi())
|
||||
|
||||
mayor = Mayorgotchi(list)
|
||||
def make_list(number):
|
||||
list = []
|
||||
for n in range(0,number):
|
||||
list.append(Util().make_Tamagotchi())
|
||||
return list
|
||||
|
||||
king = Kinggotchi()
|
||||
for n in range(0, 10):
|
||||
king.add_village(Mayorgotchi(make_list(startnr)))
|
||||
|
||||
screen = curses.initscr()
|
||||
curses.noecho()
|
||||
@@ -24,11 +28,10 @@ screen.nodelay(1)
|
||||
|
||||
while True:
|
||||
screen.move(0,0)
|
||||
mayor.step()
|
||||
screen.addstr('Simulation running. Press [q] to exit.\n')
|
||||
screen.addstr('----------------------After '+str(ticks)+' ticks------------------------------\n')
|
||||
#screen.addstr(mayor.give_status(show_pct))
|
||||
screen.addstr(mayor.give_overview())
|
||||
screen.addstr(king.show_kingdom())
|
||||
king.step()
|
||||
ticks += 1
|
||||
|
||||
screen.clrtobot()
|
||||
|
||||
Reference in New Issue
Block a user