replaced tabs with spaces
This commit is contained in:
@@ -2,43 +2,41 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from config import *
|
||||
from mayorgotchi import Mayorgotchi
|
||||
import names
|
||||
import random
|
||||
|
||||
class Kinggotchi:
|
||||
myvillages = []
|
||||
name = ''
|
||||
myvillages = []
|
||||
name = ''
|
||||
|
||||
def __init__(self):
|
||||
self.name = names.get_last_name()
|
||||
def __init__(self):
|
||||
self.name = names.get_last_name()
|
||||
|
||||
def add_village(self, mayor):
|
||||
self.myvillages.append(mayor)
|
||||
def add_village(self, mayor):
|
||||
self.myvillages.append(mayor)
|
||||
|
||||
def show_kingdom(self):
|
||||
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'
|
||||
def show_kingdom(self):
|
||||
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()
|
||||
for n in self.myvillages:
|
||||
# result += '-----------------------------------------------------------------------------------------\n'
|
||||
result += n.give_overview()
|
||||
|
||||
return result
|
||||
return result
|
||||
|
||||
def step(self):
|
||||
for n in self.myvillages:
|
||||
n.step()
|
||||
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_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
|
||||
def all_dead(self):
|
||||
result = 0
|
||||
for n in self.myvillages:
|
||||
result += n.graveyard
|
||||
return result
|
||||
|
||||
|
||||
|
||||
@@ -69,27 +69,27 @@ class Tamagotchi:
|
||||
self.power -= 1
|
||||
|
||||
def step(self):
|
||||
self.update_status()
|
||||
self.update_status()
|
||||
|
||||
if self.status is 'Eating':
|
||||
self.update_stat(self.hunger,True)
|
||||
else:
|
||||
self.update_stat(self.hunger,False)
|
||||
if self.status is 'Eating':
|
||||
self.update_stat(self.hunger,True)
|
||||
else:
|
||||
self.update_stat(self.hunger,False)
|
||||
|
||||
if self.status is 'Sleeping':
|
||||
self.update_stat(self.sleep,True)
|
||||
else:
|
||||
self.update_stat(self.sleep,False)
|
||||
if self.status is 'Sleeping':
|
||||
self.update_stat(self.sleep,True)
|
||||
else:
|
||||
self.update_stat(self.sleep,False)
|
||||
|
||||
if self.status is 'Bathing':
|
||||
self.update_stat(self.hygiene,True)
|
||||
else:
|
||||
self.update_stat(self.hygiene,False)
|
||||
if self.status is 'Bathing':
|
||||
self.update_stat(self.hygiene,True)
|
||||
else:
|
||||
self.update_stat(self.hygiene,False)
|
||||
|
||||
if self.status is 'Playing':
|
||||
self.update_stat(self.happiness,True)
|
||||
else:
|
||||
self.update_stat(self.happiness,False)
|
||||
if self.status is 'Playing':
|
||||
self.update_stat(self.happiness,True)
|
||||
else:
|
||||
self.update_stat(self.happiness,False)
|
||||
|
||||
def is_dead(self):
|
||||
if self.dead:
|
||||
|
||||
68
test.py
68
test.py
@@ -15,14 +15,14 @@ villagenr = 0
|
||||
percentage = True
|
||||
|
||||
def make_list(number):
|
||||
list = []
|
||||
for n in range(0,number):
|
||||
list.append(Util().make_Tamagotchi())
|
||||
return list
|
||||
tmp = []
|
||||
for n in range(0,number):
|
||||
tmp.append(Util().make_Tamagotchi())
|
||||
return tmp
|
||||
|
||||
king = Kinggotchi()
|
||||
for n in range(0, 30):
|
||||
king.add_village(Mayorgotchi(make_list(startnr)))
|
||||
king.add_village(Mayorgotchi(make_list(startnr)))
|
||||
|
||||
stdscr = curses.initscr()
|
||||
curses.noecho()
|
||||
@@ -34,37 +34,37 @@ height,width = stdscr.getmaxyx()
|
||||
win = curses.newpad(16383, width)
|
||||
|
||||
while True:
|
||||
win.move(0,0)
|
||||
win.addstr(0,0,'Tamagotchi Colony (alpha) - currently at tick '+str(ticks)+'.\n')
|
||||
win.move(0,0)
|
||||
win.addstr(0,0,'Tamagotchi Colony (alpha) - currently at tick '+str(ticks)+'.\n')
|
||||
|
||||
if kingdomview:
|
||||
win.addstr(2,0,'[q]:Exit [p]:Pause [v]:Village View\n')
|
||||
win.addstr(4,0,king.show_kingdom())
|
||||
else:
|
||||
win.addstr(2,0,'[q]:Exit [p]:Pause [v]:Kingdom View [n/m]:Previous/Next Village\n')
|
||||
win.addstr(4,0,king.myvillages[villagenr].give_status(percentage))
|
||||
if kingdomview:
|
||||
win.addstr(2,0,'[q]:Exit [p]:Pause [v]:Village View\n')
|
||||
win.addstr(4,0,king.show_kingdom())
|
||||
else:
|
||||
win.addstr(2,0,'[q]:Exit [p]:Pause [v]:Kingdom View [n/m]:Previous/Next Village\n')
|
||||
win.addstr(4,0,king.myvillages[villagenr].give_status(percentage))
|
||||
|
||||
king.step()
|
||||
ticks += 1
|
||||
win.clrtoeol()
|
||||
win.clrtobot()
|
||||
win.refresh(0, 0, 0, 0, height-1, width-1)
|
||||
king.step()
|
||||
ticks += 1
|
||||
win.clrtoeol()
|
||||
win.clrtobot()
|
||||
win.refresh(0, 0, 0, 0, height-1, width-1)
|
||||
|
||||
key = stdscr.getch()
|
||||
if key == ord('q'):
|
||||
break
|
||||
elif key == ord('p'):
|
||||
while True:
|
||||
unpause_key =stdscr.getch()
|
||||
if unpause_key == ord('p'):
|
||||
break
|
||||
elif key == ord('v'):
|
||||
kingdomview = not kingdomview
|
||||
elif key == ord('n'):
|
||||
villagenr -= 1
|
||||
elif key == ord('m'):
|
||||
villagenr += 1
|
||||
elif key < 0:
|
||||
time.sleep(ticklenght)
|
||||
key = stdscr.getch()
|
||||
if key == ord('q'):
|
||||
break
|
||||
elif key == ord('p'):
|
||||
while True:
|
||||
unpause_key =stdscr.getch()
|
||||
if unpause_key == ord('p'):
|
||||
break
|
||||
elif key == ord('v'):
|
||||
kingdomview = not kingdomview
|
||||
elif key == ord('n'):
|
||||
villagenr -= 1
|
||||
elif key == ord('m'):
|
||||
villagenr += 1
|
||||
elif key < 0:
|
||||
time.sleep(ticklenght)
|
||||
|
||||
curses.endwin()
|
||||
|
||||
Reference in New Issue
Block a user