Card system in Developer Help
|
|
I'm trying to make a card game (not like bridge, 31, or blackjack) thats like ummm.. those cards with monsters on them and they fight. Like Magic, Yugioh, or Pokemon. But I don't know where to start. I have my basic Idea, the icons, and the battle start code. But I don't know where to begin for drawing cards,playing cards, discarding cards, and ect.
If you have any ideas it would be greatly helpful. I'll post what I have right now just in-case you need to see it to help:
obj table marker var/filled = 0 var/mob P1 P2 var/turn = 1 Playingfield var/mob player1 player2 Click() switch(alert("Would you like to have a card battle here?","Card Table","Yes","No")) if("Yes") if(src.player1 == null) view(8)<<"[usr] sits down at the table" src.player1 = usr usr.waiting = 1 if(src.player1 != usr && src.player2 == null) src.player2 = usr usr.waiting = 1 usr.opponent = src.player1 src.player1.opponent = src.player2 view(8)<<"Let the battle begin!" StartBattle(src.player1,src.player2)
mob var waiting = 0 mob/opponent obj/list/deck = list() obj/table/marker/battlefield obj/draw/draw Move() if(src.waiting == 0) ..()
proc StartBattle(mob/P1,mob/P2) P1.loc = null P2.loc = null P1.battlefield = null P2.battlefield = null for(var/obj/table/marker/M in world) if(M.filled == 0) M.filled = 1 P1.battlefield = M for(var/obj/table/marker/M in world) if(M.filled == 0) M.filled = 1 P2.battlefield = M if(P1.battlefield && P2.battlefield) Decide_Turns(P1,P2) Decide_Turns(mob/P1,mob/P2) var/first = 0 switch(alert(P1,"Heads or tails?","Turn order","Heads","Tails")) if("Heads") P2<<"[P1] calls heads!" P1<<"You call heads!" sleep(1) var/side = rand(1,2) if(side == 1) P2<<"Heads! [P1] Goes first!" P1<<"Heads! You go first!" first = 1 if(side == 2) P2<<"Tails! You go first!" P1<<"Tails! [P2] Goes first!" first = 2 if("Tails") P2<<"[P1] calls Tails!" P1<<"You call Tails!" sleep(1) var/side = rand(1,2) if(side == 1) P1<<"Heads! [P2] Goes first!" P2<<"Heads! You go first!" first = 2 if(side == 2) P1<<"Tails! You go first!" P2<<"Tails! [P1] Goes first!" first = 1 if(first == 1) setbattle(P1,P2) if(first == 2) setbattle(P2,P1) setbattle(mob/P1,mob/P2) P1.draw = new/obj/draw(locate(P1.battlefield.x+3,P1.battlefield.y-4,P1.battlefield.z))
|
All help is very appreiciated =D
|
Visualize for a moment what a playing area would look like. There would be particular places to put cards, including your draw deck and discard pile. Cards would often be stackable in most games, but in many they never overlap otherwise or always do so in a spread pattern (e.g. standard Klondike solitaire, Freecell). Sometimes you'd want to be able to orient cards a certain way.
So this gives us something to work with to start out. You need datums to represent each portion of the playing field, and to represent stacks of cards.
Anyway, here's the plan: Any time you want to display cards on the table, you create a /stack datum and add those cards to it, and add that stack to the appropriate /playbox. (Usually you'd set up playboxes at the beginning of the game.) Whenever you use an obj (or more than one) to display a visible card, tell the obj(s) which stack that card belongs to. Any display objects should have a var telling them which stack they belong to, so Click() and DblClick() and such can be passed along.
Lummox JR