breakfunc-continuefunc command
Posted: Sat Aug 18, 2018 10:29 pm
after notice: Seems I wasnt able to make this very clear. If it seems difficult to undersatnd, i will send you simpler version.
To get this idea better, is to explain real case situation.
I am making this card game just to practice some new coding technics, and there is constantly one problem that i encounter all the time which makes the code very messy.
Situation is this.
1. Player chooses to build one of his cards.
2. After choosing which card to build, he needs to choose which cards to use to pay it.
3. in case payment is not exact payment, he needs to choose which cards to take as change (basically, if you buy 2 euro stuff, and you pay with 5 euro sedel, you then get to choose what kind of change to get back.
As I am trying to do this all using WaitEvent() system, I cant really figure out how to do this any simple and clean way, but I have to make several functions:
a whole load of trouble and load of functions.
What I would like to be able to do, would be soemthing like this:
I guess you can see the benefit yourself about how much easier this code is to read and find out what is happening in that building buying place, than the previous one where first part of things happen in first function, next part in next function etc. With this everything can basically happen in this one function only, so you only need to read that one function through to figure out what is happening there, instead of keep jumping from one function to next to see what is happening.
Would this be doable?
To get this idea better, is to explain real case situation.
I am making this card game just to practice some new coding technics, and there is constantly one problem that i encounter all the time which makes the code very messy.
Situation is this.
1. Player chooses to build one of his cards.
2. After choosing which card to build, he needs to choose which cards to use to pay it.
3. in case payment is not exact payment, he needs to choose which cards to take as change (basically, if you buy 2 euro stuff, and you pay with 5 euro sedel, you then get to choose what kind of change to get back.
As I am trying to do this all using WaitEvent() system, I cant really figure out how to do this any simple and clean way, but I have to make several functions:
Code: Select all
Function makebuildablecardspickable
foreach card
if card = buildable card then card.leftmousebuttonfunction=pickingbuildingcard
next
endfunction
function pickingbuildingcard
resetcardsleftmousefunctions()
makepricecardschoosable()
price = card.price
endfunction
function resetcardsleftmousefunction()
foreach card
card.leftmousebuttonfunction = fefaultfunction
next
endfunction
function makepricecardschoosable()
foreach card
if card = pricecard then card.leftmousebuttonfunction=payabuilding
next
endfunction
function payabuilding
price = price - card.price
if price = 0 donepaying
if price < 0 then getchange
endfunction
function getchange
---
endfunction
What I would like to be able to do, would be soemthing like this:
Code: Select all
Function BuildABuilding
foreach card
if card = buildable card then card.leftmousebuttonfunction=pickingbuildingcard
next
breakfunc(1)
resetcardsleftmousefunctions()
makepricecardschoosable()
price = card.price
endfunction
breakfunc(1)
price = price - card.price
if price = 0 donepaying
if price < 0 then getchange
endfunction
function pickingbuildingcard()
continuefunc(1)
endfunction
function payabuilding
continuefunc(1)
endfunction
function
Would this be doable?