Moved all test functions to cli class
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
*.pyo
|
*.pyo
|
||||||
*.pyc
|
*.pyc
|
||||||
|
*.swp
|
||||||
|
|||||||
17
cli.py
17
cli.py
@@ -1,6 +1,8 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# coding=UTF-8
|
# coding=UTF-8
|
||||||
|
|
||||||
|
from mayorgotchi import Mayorgotchi
|
||||||
|
from kinggotchi import Kinggotchi
|
||||||
from config import *
|
from config import *
|
||||||
import curses
|
import curses
|
||||||
import time
|
import time
|
||||||
@@ -10,8 +12,10 @@ class cursesUI:
|
|||||||
villagenr = 0
|
villagenr = 0
|
||||||
percentage = True
|
percentage = True
|
||||||
running = True
|
running = True
|
||||||
|
ticks = 0
|
||||||
def __init__(self,start_paused):
|
king = Kinggotchi()
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
self.kingdomview = True
|
self.kingdomview = True
|
||||||
self.villagenr = 0
|
self.villagenr = 0
|
||||||
self.percentage = True
|
self.percentage = True
|
||||||
@@ -26,6 +30,15 @@ class cursesUI:
|
|||||||
|
|
||||||
height, width = self.stdscr.getmaxyx()
|
height, width = self.stdscr.getmaxyx()
|
||||||
self.win = curses.newpad(16383, width)
|
self.win = curses.newpad(16383, width)
|
||||||
|
|
||||||
|
self.king.createKingdom(50)
|
||||||
|
|
||||||
|
while self.running:
|
||||||
|
self.build_screen(self.king, self.ticks)
|
||||||
|
|
||||||
|
if not self.paused:
|
||||||
|
self.king.step()
|
||||||
|
self.ticks += 1
|
||||||
|
|
||||||
def build_screen(self, king, ticks):
|
def build_screen(self, king, ticks):
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,6 @@
|
|||||||
ticklenght = 0.001
|
ticklenght = 0.001
|
||||||
# Number of Tamagotchis to be created at the start of the simulation
|
# Number of Tamagotchis to be created at the start of the simulation
|
||||||
startnr = 60
|
startnr = 60
|
||||||
# The amount of points a Tamagotchi loses per tick
|
|
||||||
decayaspeed = 1
|
|
||||||
# If the hunger stat falls below this level Tamagotchis can be fed
|
# If the hunger stat falls below this level Tamagotchis can be fed
|
||||||
feeding_point = 50
|
feeding_point = 50
|
||||||
# If the hygiene stat falls below this level Tamagotchis can be washed
|
# If the hygiene stat falls below this level Tamagotchis can be washed
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from config import *
|
from config import *
|
||||||
|
from mayorgotchi import Mayorgotchi
|
||||||
|
from util import Util
|
||||||
import names
|
import names
|
||||||
|
import itertools
|
||||||
|
|
||||||
class Kinggotchi:
|
class Kinggotchi:
|
||||||
myvillages = []
|
myvillages = []
|
||||||
@@ -36,4 +39,8 @@ class Kinggotchi:
|
|||||||
result = 0
|
result = 0
|
||||||
for n in self.myvillages:
|
for n in self.myvillages:
|
||||||
result += n.graveyard
|
result += n.graveyard
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def createKingdom(self, startvillages):
|
||||||
|
for _ in itertools.repeat(None, startvillages):
|
||||||
|
self.add_village(Mayorgotchi(Util().make_list_of_Tamagotchis(startnr)))
|
||||||
|
|||||||
24
test.py
24
test.py
@@ -1,28 +1,6 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# coding=UTF-8
|
# coding=UTF-8
|
||||||
|
|
||||||
from mayorgotchi import Mayorgotchi
|
|
||||||
from kinggotchi import Kinggotchi
|
|
||||||
from util import Util
|
|
||||||
from config import *
|
|
||||||
from cli import *
|
from cli import *
|
||||||
import time
|
|
||||||
import curses
|
|
||||||
|
|
||||||
# Temporary test section
|
ui = cursesUI()
|
||||||
ticks = 0
|
|
||||||
king = Kinggotchi()
|
|
||||||
ui = cursesUI(True)
|
|
||||||
|
|
||||||
for n in range(0, 50):
|
|
||||||
king.add_village(Mayorgotchi(Util().make_list_of_Tamagotchis(startnr)))
|
|
||||||
|
|
||||||
while True:
|
|
||||||
ui.build_screen(king, ticks)
|
|
||||||
|
|
||||||
if not ui.paused:
|
|
||||||
king.step()
|
|
||||||
ticks += 1
|
|
||||||
if not ui.running:
|
|
||||||
break
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user