Notes
![]() ![]() Notes - notes.io |
"This method is the main of the game. The hero selection, buying items etc. and the turn-based game is implemented in this method."
| firstPlayerChoice secondPlayerChoice chosenItem1 chosenItem2 item i j|
firstPlayerChoice := UIManager default chooseFrom: self getScourgeSet message: 'Choose a hero from Scourge list for Player 1'.
firstPlayerChoice = 1
ifTrue:[firstPlayer := Leshrac new.].
firstPlayerChoice = 2
ifTrue:[firstPlayer := Lion new.].
firstPlayerChoice = 3
ifTrue:[firstPlayer := Mortred new.].
firstPlayerChoice = 4
ifTrue:[firstPlayer := NyxAssassin new.].
firstPlayerChoice = 5
ifTrue:[firstPlayer := SkeletonKing new.].
firstPlayerChoice = 6
ifTrue:[firstPlayer := Tidehunter new.].
secondPlayerChoice := UIManager default chooseFrom: self getSentinelSet message: 'Choose a hero from Sentinel list for Player 2'.
secondPlayerChoice = 1
ifTrue:[secondPlayer := Earthshaker new.].
secondPlayerChoice = 2
ifTrue:[secondPlayer := Magina new.].
secondPlayerChoice = 3
ifTrue:[secondPlayer := Mirana new.].
secondPlayerChoice = 4
ifTrue:[secondPlayer := OgreMagi new.].
secondPlayerChoice = 5
ifTrue:[secondPlayer := Rylai new.].
secondPlayerChoice = 6
ifTrue:[secondPlayer := Sven new.].
"secondPlayerChoice = 1
ifTrue:[secondPlayer := Magina createNewHeroInstance.] ifFalse:[secondPlayer := OgreMagi createNewHeroInstance.]."
"chosenItem1:= Item new."
i:=4.
[ (i > 0) &(firstPlayer getGold >0)] whileTrue: [
chosenItem1 := UIManager default chooseFrom: self getItemSet message: 'Choose an Item for Player 1 Gold ', firstPlayer getGold asString.
"firstPlayer setItemList: chosenItem1 ."
chosenItem1 = 1
ifTrue:[item := BattleFury new.].
chosenItem1= 2
ifTrue:[item := Butterfly new.].
chosenItem1 = 3
ifTrue:[item:= Deadalus new.].
chosenItem1= 4
ifTrue:[item := Desolator new.].
chosenItem1 = 5
ifTrue:[item := EnergyBooster new.].
chosenItem1 = 6
ifTrue:[item := HealthPotion new.].
chosenItem1 = 7
ifTrue:[item := HeartofTarrasque new.].
chosenItem1 = 8
ifTrue:[item := HoodofDefiance new.].
chosenItem1 = 9
ifTrue:[item := ManaPotion new.].
chosenItem1 = 10
ifTrue:[item := SkullBasher new.].
chosenItem1 = 11
ifTrue:[item := Vanguard new.].
chosenItem1 = 12
ifTrue:[item := VitalyBooster new.].
i:= (i-1) .
item getCost < firstPlayer getGold
ifTrue: [
firstPlayer setItemList: item.
firstPlayer setGold: firstPlayer getGold - item getCost ].
].
j:=4.
[ (j > 0) &(secondPlayer getGold>0)] whileTrue: [
chosenItem2 := UIManager default chooseFrom: self getItemSet message: 'Choose an Item for Player 2 Gold: ', secondPlayer getGold asString .
chosenItem2 = 1
ifTrue:[item := BattleFury new.].
chosenItem2= 2
ifTrue:[item:= Butterfly new.].
chosenItem2 = 3
ifTrue:[item:= Deadalus new.].
chosenItem2= 4
ifTrue:[item := Desolator new.].
chosenItem2= 5
ifTrue:[item := EnergyBooster new.].
chosenItem2 = 6
ifTrue:[item := HealthPotion new.].
chosenItem2 = 7
ifTrue:[item := HeartofTarrasque new.].
chosenItem2 = 8
ifTrue:[item := HoodofDefiance new.].
chosenItem2 = 9
ifTrue:[item := ManaPotion new.].
chosenItem2= 10
ifTrue:[item := SkullBasher new.].
chosenItem2 = 11
ifTrue:[item := Vanguard new.].
chosenItem2 = 12
ifTrue:[item := VitalyBooster new.].
j:=(j-1).
item getCost <secondPlayer getGold
ifTrue:[
secondPlayer setItemList: item.
secondPlayer setGold: secondPlayer getGold- item getCost
]
].
"chosenItem2 := UIManager default chooseFrom: self getItemSet message: 'Choose an Item for Player 2'.
secondPlayer setItemList: chosenItem2 ."
"Transcript open;cr;show:(firstPlayer getItemList)."
"Transcript open;cr;show:(secondPlayer getMaxHp)."
"chosenItem = 1
ifTrue: [firstPlayer setItemList: (BattleFury createNewItem).] ifFalse: [ firstPlayer setItemList: (Potion createNewItem ).]."
"So far, we have chosen our heroes and buy items for them, now it is turn to play the game"
"Transcript clear.
[((firstPlayer getHP) ~= 0) & ((secondPlayer getHP) ~= 0)]
whileTrue: [Transcript open; show: 'The game is started...';cr; show:'The HP of First Player is '; show:(firstPlayer getHP);cr;show:'The HP of the Second Player is ';show:(secondPlayer getHP). firstPlayer setHP:0.].
""If HP of an hero reaches to zero, the game ends as it goes out of the loop"."
Transcript open; cr;show:'The game is finished'."
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team