Last active
August 29, 2015 14:05
-
-
Save PifyZ/d012774290516f67eb48 to your computer and use it in GitHub Desktop.
Cardman
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import mojo.graphics | |
Import monster | |
Class Face Abstract | |
Const EXPOSED := 0 | |
Const COVERED := 1 | |
End | |
Class Position Abstract | |
Const ATTACK := 0 | |
Const DEFENSE := 1 | |
End | |
Class Card | |
Private | |
Field monster:Monster | |
Field bonusAttack:Int | |
Field bonusDefense:Int | |
Field face:Int | |
Field position:Int | |
Field column:Int | |
Field line:Int | |
Public | |
Method New(monster:Monster) | |
Self.monster = monster | |
bonusAttack = 0 | |
bonusDefense = 0 | |
face = Face.EXPOSED | |
position = Position.ATTACK | |
column = -1 | |
line = -1 | |
End | |
Method AddBonusAttack:Void(bonus:Int) | |
Self.bonusAttack += bonus | |
End | |
Method SubBonusAttack:Void(malus:Int) | |
Self.bonusAttack -= malus | |
End | |
Method AddBonusDefense:Void(bonus:Int) | |
Self.bonusDefense += bonus | |
End | |
Method SubBonusDefense:Void(malus:Int) | |
Self.bonusDefense -= malus | |
End | |
Method Draw() | |
SetColor(255, 0, 0) | |
DrawRect(20, 20, 20, 20) | |
End | |
' Getters | |
Method Monster:Monster() Property | |
Return monster | |
End | |
Method BonusAttack:Int() Property | |
Return bonusAttack | |
End | |
Method BonusDefense:Int() Property | |
Return bonusDefense | |
End | |
Method Attack:Int() Property | |
Return monster.Attack + bonusAttack | |
End | |
Method Defense:Int() Property | |
Return monster.Defense + bonusDefense | |
End | |
End |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import card | |
Class Deck | |
Private | |
Field cards:Stack<Card> | |
Public | |
Method New(cards:Stack<Card>) | |
Self.cards = cards | |
End | |
Method AddCard:Void(card:Card) | |
cards.Push(card) | |
End | |
Method PickCard:Card() | |
cards.Remove(0) | |
End | |
' Getters | |
Method Cards:Stack<Card>() Property | |
Return cards | |
End | |
End |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import mojo | |
Import monster | |
Import deck | |
Function Main:Int() | |
New Game() | |
Return 0 | |
End | |
Class Game Extends App | |
Private | |
Field gameField:GameField | |
Public | |
Method OnCreate:Int() | |
SetUpdateRate(60) | |
gameField = New GameField() | |
Return 0 | |
End | |
Method OnUpdate:Int() | |
gameField.Update() | |
Return 0 | |
End | |
Method OnRender:Int() | |
gameField.Draw() | |
Return 0 | |
End | |
End | |
Class GameField | |
Private | |
Field monsters:Stack<Monster> | |
Field cards:Stack<Card> | |
Field deck:Deck | |
Public | |
Method New() | |
monsters = new Stack<Monster>() | |
monsters.Push(new Monster("A", "AAA", 1000, 2000, Null)) | |
monsters.Push(new Monster("B", "BBB", 2200, 800, Null)) | |
cards = new Stack<Card>() | |
cards.Push(new Card(monsters.Get(0))) | |
cards.Push(new Card(monsters.Get(1))) | |
deck = New Deck(cards) | |
For Local card:Card = Eachin deck.Cards | |
Print(card.Monster.Name) | |
End | |
End | |
Method Update:Void() | |
End | |
Method Draw:Void() | |
SetColor(255, 0, 0) | |
DrawRect(0, 0, 200, 200) | |
End | |
End |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import mojo | |
Class Monster | |
Private | |
Field name:String | |
Field description:String | |
Field attack:Int | |
Field defense:Int | |
Field width:Int | |
Field height:Int | |
Field img:Image | |
Field imgHover:Image | |
Public | |
Method New(name:String, description:String, attack:Int, defense:Int, img:Image) | |
Self.name = name | |
Self.description = description | |
Self.attack = attack | |
Self.defense = defense | |
If img <> Null | |
Self.img = img | |
imgHover = Self.img ' todo | |
width = Self.img.Width | |
height = Self.img.Height | |
End | |
End | |
' Getters | |
Method Name:String() Property | |
Return name | |
End | |
Method Description:String() Property | |
Return Description | |
End | |
Method Attack:Int() Property | |
Return attack | |
End | |
Method Defense:Int() Property | |
Return defense | |
End | |
Method Width:Int() Property | |
Return width | |
End | |
Method Height:Int() Property | |
Return height | |
End | |
Method Img:Image() Property | |
Return img | |
End | |
Method ImgHover:Image() Property | |
Return imgHover | |
End | |
End |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import deck | |
Import card | |
Class Player | |
Private | |
Field deck:Deck | |
Public | |
Method New(deck:Deck) | |
Self.deck = deck | |
End | |
End |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment