Well, I'm happy to answer specific questions, but like, dude, at some point you're kind of asking me to code your game for you and a) I'm not going to, and b) I can't.
The problem is, as much as you say you'd like to deal with one thing at a time, you can't. How you want to show the screens will affect how you set up your classes, and how you set up your classes will affect how you set up your screens and your turn-based "engine", so to speak. What you're trying to accomplish isn't super difficult, but it has a lot of moving parts, and there are multiple ways you could set it up, each more or less suited to specific goals. I can't do that for you, you have to decide how you want to do it.
That said, I can answer the questions you have about the code, at least.
Code: Select all
init -2 python:
turn = 0
researching = None
current_research = None
research_points_bonus = 30
ship_damage = 5 ## default value
init -1 python:
class research():
def __init__(self, name, cost, type, description, progress = 0, unlocked=False, researched=False):
self.name = name
self.cost = cost
self.type = type
self.description = description
self.progress = progress
self.unlocked = unlocked
self.researched = researched
def add_branch(self, branch1, branch2): ## I don't understand exactly how this work why branch1 and branch2 is in () with self // branch1 and branch2 are just argument names. They can be anything. I just added these to show how you can link one tech to another -- there are other ways to do it as well. This is just one way you can link Fusion Bomb with tech1 and tech2, so that finishing Fusion Bomb automatically unlocks tech 1 and tech 2. If you want, you can further expand that so if you finish tech 1, it will "relock" tech 2, which is a concept you mentioned briefly.
self.branch1 = branch1
self.branch2 = branch2
def check_if_finished(self):
if self.progress > self.cost:
self.researched = True ## why not 0 for false and 1 for true it takes less space can I do something specific with true false answers? // No, I just find True and False more readable.
research_points_ammount = 0
self.branch1.unlocked = True
self.branch2.unlocked = True
else:
return
init python:
fusion_bomb = research("Fusion Bomb", 55, "Weaponry", "Fusion Bomb technology description", unlocked=True)
other_tech = research("Other", 55, "Other", "Other", unlocked=True)
branch1 = research("Branch1", 65, "Weaponry", "branch1")
branch2 = research("Branch2", 65, "Weaponry", "branch2") ## someting weirds happens in code after researching fusion bomb if I'll quit to main menu and then start new game I have fusion bomb researched already. // That would be why my original code put these after start instead of in init...
fusion_bomb.add_branch(branch1, branch2) ## since there are already four technologies, fusion_bomb, other_tech, branch1, and branch2, all this does is "link" branch1 and branch2 into fusion_bomb so that they can be easily identified in relation to fusion_bomb.
label start:
"this is the start of the game"
jump upkeep_phase
label upkeep_phase:
$ turn += 1
"Turn [turn]"
if researching == None:
jump choose_research_menu
else:
$ researching.check_if_finished()
$ researching.progress += research_points_bonus ##why research.progress doesn't work? Why does it have to be researching.progress? // researching is the arbitrary variable name I chose for the tech that is currently being researched. I initialized it to None in an init block, and choose_research_menu sets researching based on your choices. researching is just referring to whichever Research object is chosen. You can name it whatever you want. I assumed here that you can only research one project at a time. That may not be what you envision. I don't know.
if researching.researched == True: ##Here I have questio. How I can refer to specific technology? a lot of them will add different stuff // I'll address this separately after the code block.
"You finished researching [researching.name]."
$ researching = None
Luxliev wrote:I really need to know how if this is possible I can add functions like fe this ship_damage += 1 in fusion bomb upgrade.
Look, again, there are a LOT of ways you could do this but it takes time and thought and the best way to do it will depend on what exactly you want to do, which I don't know. How are you going to set up the rest of your stats? Is your ship an object (i.e., are the related stats part of a Ship object)? Are the stats simple variables? One of the screenshots you posted shows that a perk may grant +1 to research points. Is that a simple variable? Is it part of something else, like a Civilization object that can grant various bonuses to fighting or research or whatever? Will research bonuses be purely stat/numerical like ship defense +1? Will they involve boolean flags -- like if you have research X you can do Y but otherwise you can't? (Note: These are rhetorical questions.) I can't code this for you because I don't know. And you can try to explain it to me on this forum but I STILL won't know, because it's not my game.
You said you want to do things one at a time. If so, that's going to involve a LOT of trial and error. You'll build it this research module one way based on text menus, just to get the functionality down, and then realize you have to rejigger it all to make it work efficiently on GUI screens. You'll finish this research thing and then try to go implement different races and find that you have to rehaul all the research code. You'll finish implementing races and then realize now your battle code is going to be fifty billion lines long unless you make the race and research parts more efficient. It's going to suck, but that's a process you're going to have to go through unless you're willing to hire someone else to do the coding for you.
That said, assuming that all the research perks will ONLY involve permanent stat changes, you could easily reconfigure the Research class like so.
Code: Select all
python:
class Research():
def __init__(self, name, cost, type, description, stat_effect, progress=0, researched=False, unlocked=False):
self.name = name
self.cost = cost
self.type = type
self.stat_effect = stat_effect ## added this
self.description = description
self.progress = progress
self.researched = researched
self.unlocked = unlocked
def add_branch(self, branch1, branch2):
self.branch1 = branch1
self.branch2 = branch2
def check_if_finished(self):
if self.progress > self.cost:
self.researched = True
self.branch1.unlocked = True
self.branch2.unlocked = True
## here is where the ifs and type/stat_effect come in
if self.type == "Weaponry":
ship_guns += self.stat_effect
if self.type == "Defense":
ship_defense += self.stat_effect
else:
return
But again, the more diverse you want your effects to be, the more carefully you will have to consider how you want to code that.
As for the screens, a basic set-up will involve some for loops. For example, the following screen will show four boxes stacked vertically with basic name and researched info. Where you go from here is a matter of designing good screens, which is again, something you will have to do.
Code: Select all
python:
research_list = [fusion_bomb, other_tech, branch1, branch2]
screen research_screen():
for item in research_list:
vbox:
vbox:
text "[item.name]"
if item.researched == True:
text "Finished."
else:
text "[item.progress] / [item.cost] researched."