przebudowa app, dodanie funkcji stats

This commit is contained in:
sysek 2025-01-20 21:21:47 +01:00
parent a29e8338bf
commit 2ca910d2eb
6 changed files with 136 additions and 72 deletions

4
.gitignore vendored
View file

@ -8,3 +8,7 @@ __pycache__
auto-save-list auto-save-list
.\#* .\#*
.kateproject .kateproject
#### project
db/
dev/

39
app.py
View file

@ -1,13 +1,10 @@
from engine import Engine
from game import Game from game import Game
from player import Player from player import Player
from enemy import Enemy from enemy import Enemy
# ENGINE SECTION
eng = Engine()
# GAME SECTION # GAME SECTION
game = Game() game = Game()
STATs = game.stats()
# PLAYER SECTION # PLAYER SECTION
player = Player("キーウィ") player = Player("キーウィ")
@ -30,9 +27,9 @@ def logo():
print(logo) print(logo)
loop = True def menu():
while loop is True: running = True
logo() while running:
if player is False: if player is False:
print("--- CREATE CHARACTER ___") print("--- CREATE CHARACTER ___")
game.create_character() game.create_character()
@ -43,13 +40,29 @@ while loop is True:
print("戦う [f]ight mode") print("戦う [f]ight mode")
print("顔 show [c]haracter") print("顔 show [c]haracter")
# breakpoint()
timetochoose = input(">___ ") timetochoose = input(">___ ")
if timetochoose == "Q" or timetochoose == "q": if timetochoose == "Q" or timetochoose == "q":
loop = False running = False
break
elif timetochoose == "F" or timetochoose == "f": elif timetochoose == "F" or timetochoose == "f":
print("### tutaj będzie fight mode ###") breakpoint()
# game.figth_mode() game.clean_screen()
elif timetochoose == 'C' or timetochoose == 'c': winorloose = game.figth_mode(player, dummykid)
player.show_stats() if winorloose == 0:
print("### BRAK WALKI ###")
else:
print("LET'S FIGHT")
elif timetochoose == "C" or timetochoose == "c":
game.clean_screen()
player.show_stats(stats=STATs)
def main():
game.clean_screen()
logo()
menu()
if __name__ == "__main__":
main()

View file

@ -1,11 +1,7 @@
class Enemy: class Enemy:
def __init__(self): def __init__(self):
self.name = "Dummy" self.name = "Dummy"
self.hp = 10 self.HP = 10
self.mp = 0
def show_dummy(self): def show_dummy(self):
print(f"Name: {self.name}") print(f"Name: {self.name}")

View file

@ -1,13 +0,0 @@
import random
from os import system
class Engine:
def roll_d20(self):
return random.randint(1, 20)
def roll_d10(self):
return random.randint(1, 10)
def roll_d6(self):
return random.randint(1, 6)

87
game.py
View file

@ -1,28 +1,95 @@
# from engine import Engine from os import system, name
from random import randint
from player import Player from player import Player
from enemy import Enemy from enemy import Enemy
class Game: class Game:
def roll_d20(self):
return randint(1, 20)
def roll_d10(self):
return randint(1, 10)
def roll_d6(self):
return randint(1, 6)
def clean_screen(self):
if name == "nt":
_ = system("cls")
else:
_ = system("clear")
def figth_mode(self, player: Player, enemy: Enemy): def figth_mode(self, player: Player, enemy: Enemy):
""" """
--- FIGHT MODE ___ --- FIGHT MODE ___
player: Player Class player: Player Class
enemy: Enemy Class enemy: Enemy Class
"""
print("--- FIGHT MODE ___") Funkcja wykorzystywana w przypadku gdy gracz napotka na przeciwnika.
Jest to bardzo wczesna funkcja do rozbudowania.
"""
STATUS = None
FIGHT = True
MA = [1, 1]
while FIGHT:
print("### FIGHT MODE ###")
print(f"{player.name} vs. {enemy.name}") print(f"{player.name} vs. {enemy.name}")
INIT_PLAYER = self.roll_d10() INIT_PLAYER = self.roll_d10 + player.STATs["REF"]
INIT_ENEMY = self.roll_d10() INIT_ENEMY = self.roll_d10()
if INIT_PLAYER > INIT_ENEMY: PLAYER_HP = player.HP
ENEMY_HP = enemy.HP
print(f"PLAYER ROLL: {INIT_PLAYER}") print(f"PLAYER ROLL: {INIT_PLAYER}")
print(f"ENEMY ROLL: {INIT_ENEMY}") print(f"ENEMY ROLL: {INIT_ENEMY}")
print("FIGHT OFF, CHICKEN")
else:
print("YOU GOT SOME TROUBLE, MATE")
def create_character(self): if INIT_PLAYER > INIT_ENEMY:
pass print("FIGHT OFF, CHICKEN")
STATUS = 0 # brak walki
else:
self.clean_screen()
print("YOU GOT SOME TROUBLE, MATE")
STATUS = 1 # walka
count = MA.count(1)
if count > 0:
count_left = count
print(f"You have {count}/{count_left} AP")
print(f"Your HP: {player.hp}")
print(f"Enemy HP: {enemy.hp}")
print("What to do?")
choose = input(">___")
if choose == "h":
player_hit = self.roll_d6()
print(f"{player.name} hits {player_hit}")
return STATUS
def stats(self):
"""
stats: playerClass
Funkcja uzywania do wygenerowania statystyk dla gracza badz
jakiegos zbira (test)
"""
STATs = {
"INT": 0,
"REF": 0,
"DEX": 0,
"TECH": 0,
"COOL": 0,
"WILL": 0,
"LUCK": 0,
"MOVE": 0,
"BODY": 0,
"EMP": 0
}
for k, v in STATs.items():
STATs[k] = randint(1, 10)
return STATs

View file

@ -1,17 +1,15 @@
class Player: class Player:
STATs = {
"INT": 5, """
"REF": 7, Zmienna BODY - wykorzystywana do ubioru bohatera, trzymania broni etc.
"DEX": 7, """
"TECH": 7, BODY = {
"COOL": 7, "HEAD": 0,
"WILL": 5, "CHEST": 0,
"LUCK": 8, "LEFT_HAND": 0,
"MOVE": 6, "RIGHT_HAND": 0,
"BODY": 5, "LEFT_LEG": 0,
"EMP": 5 "RIGHT_LEG": 0
} }
HP = 0 HP = 0
@ -22,10 +20,9 @@ class Player:
self.HP_MAX = 35 self.HP_MAX = 35
self.name = name self.name = name
def show_stats(self): def show_stats(self, stats=None):
print(f"Name: {self.name}") print(f"Name: {self.name}")
print(f"HP: {self.HP}/{self.HP_MAX}") print(f"HP: {self.HP}/{self.HP_MAX}")
for k, v in self.STATs.items(): for k, v in stats.items():
print(f"{k}: {v}") print(k, v)