Merge pull request #2 from sysek/dev

Dev
This commit is contained in:
キーウィ 2025-01-22 07:54:54 +01:00 committed by GitHub
commit 85d468a431
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 133 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/

60
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,26 +27,41 @@ def logo():
print(logo) print(logo)
loop = True def menu():
while loop is True: running = True
while running:
if player is False:
print("--- CREATE CHARACTER ___")
game.create_character()
else:
print(f"--- HELLO {player.name} ___")
print("--- WARNING, TEST MODE ___")
print("? What you would like to do today?")
print("戦う [f]ight mode")
print("顔 show [c]haracter")
timetochoose = input(">___ ")
if timetochoose == "Q" or timetochoose == "q":
running = False
break
elif timetochoose == "F" or timetochoose == "f":
game.clean_screen()
winorloose = game.figth_mode(player, dummykid)
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() logo()
if player is False: menu()
print("--- CREATE CHARACTER ___")
game.create_character()
else:
print(f"--- HELLO {player.name} ___")
print("--- WARNING, TEST MODE ___")
print("? What you would like to do today?")
print("戦う [f]ight mode")
print("顔 show [c]haracter")
# breakpoint()
timetochoose = input(">___ ")
if timetochoose == "Q" or timetochoose == "q": if __name__ == "__main__":
loop = False main()
elif timetochoose == "F" or timetochoose == "f":
print("### tutaj będzie fight mode ###")
# game.figth_mode()
elif timetochoose == 'C' or timetochoose == 'c':
player.show_stats()

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,93 @@
# 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
Funkcja wykorzystywana w przypadku gdy gracz napotka na przeciwnika.
Jest to bardzo wczesna funkcja do rozbudowania.
""" """
STATUS = None
FIGHT = True
MA = [1, 1]
print("--- FIGHT MODE ___") while FIGHT:
print(f"{player.name} vs. {enemy.name}") print("### FIGHT MODE ###")
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()
PLAYER_HP = player.HP
ENEMY_HP = enemy.HP
if INIT_PLAYER > INIT_ENEMY:
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):
"""
Funkcja do generowania statystyk dla gracza
"""
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,31 +1,28 @@
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
HP_MAX = 0 HP_MAX = 0
def __init__(self, name): def __init__(self, name):
self.HP = 35 self.HP = 35
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)