ID:162405
 
hi im making a duel monsters game on byond and i want to make it manual to summon and set monsters, traps, and spells but idk how to do that

this one is auto but i want it to be manual for now

obj
card
proc
MonClick(var/mob/U,var/obj/S)
src=S
usr=U
if(src!=null)
var/list/choicelist=new/list()
if(usr.isturn=="Yes")
if(src in oview())
if(usr.target=="get one")
if(src:owner!=usr)
usr.target=src
var/text="Attack [src] with [usr.currentcard]?"
if(src.stance=="Face Down")
text="Attack Face Down Card with [usr.currentcard]?"
switch(alert("[text]","Attack Target","Yes","No"))
if("Yes")
if(src.effecttime=="IsAttacked")
var/returned=src:EffectRun(usr)
if(returned=="Stop")
return
src.Attack(usr,usr.currentcard)
return
if(usr.target=="tribute")
if(src.owner==usr)
if(src in usr.tributelist)
usr<<"You have Already Selected this Monster to be Tributed!"
else
switch(alert("Tribute [src] to summon [usr.currentcard]?","Tribute Monster","Yes","No"))
if("Yes")
usr.tributelist+=src
usr.tributes+=1
if(usr.tributes>=usr.needed)
usr.target=null
Tribute(usr,usr.currentcard)
usr.GraveUpdate()
usr.PhaseUpdate(usr.phase)
return
if(src.owner==usr)
if((usr.phase=="Battle"&&src.attacked=="No")&&usr.table:turn >1)
choicelist+="Attack"
else
if((src.canturn=="Yes"&&src.justsummoned=="No")&&src.stance! ="Face Down")
choicelist+="Turn"
if(src.justsummoned=="No"&&src.stance=="Face Down")
choicelist+="Flip"
if(src in usr.hand)
if(usr.summoned=="No")
var/counter=0
for(var/obj/O in usr.monsters)
counter+=1
if(src.level<=4)
if(counter<5)
choicelist+="Summon"
if((src.level==5||src.level==6)&&counter>=1)
choicelist+="Summon"
if((src.level==7||src.level==8)&&counter>=2)
choicelist+="Summon"
if((src.level==9||src.level==10)&&counter>=3)
choicelist+="Summon"
var/counter=0
for(var/obj/O in usr.hand)
counter+=1
if(usr.phase=="Main Phase 2"&&counter>6)
choicelist+="Discard"
if(usr.dueling=="No")
if(src in usr.deck)
choicelist+="Remove from Deck"
if(src in usr.cards)
choicelist+="Add to Deck"
choicelist+="Look"
choicelist+="Check"
choicelist+="Cancel"
if(src.owner!=usr&&src.stance=="Face Down")
usr<<"You cannot view other players Face Down cards"
return
var/choice=input("([src.level]) [src.icon_state] \n[src.atk]/[src.def]","Make Selection")as anything in choicelist
if(choice=="Cancel"||choice==null)
return
if(choice=="Add to Deck")
var/counter=0
for(var/obj/X in usr.deck)
if(X.name==src.name)
counter+=1
if(counter<3)
usr.cards-=src
usr.justgot-=src
usr.deck+=src
else
usr<<"You can only have 3 of each card in your deck!"
return
if(choice=="Remove from Deck")
usr.deck-=src
usr.cards+=src
return
if(choice=="Discard")
usr.hand-=src
usr.graveyard+=src
CardNumUpdate(usr)
usr.GraveUpdate()
return
if(choice=="Attack")
if(src.stance!="Attack")
usr<<"Monsters can only attack when they are in the Attack position"
return
var/counter=0
for(var/obj/O in usr.opponent:monsters)
counter+=1
if(counter<=0)
switch(alert("Directly attack [usr.opponent]'s LP?","Attack","Yes","No"))
if("Yes")
src.attacked="Yes"
usr.target=null
usr.opponent:lp-=src.atk
var/obj/NS=new/obj/sword()
NS.dir=src.dir
NS.loc=src.loc
loop
sleep(3)
step_towards(NS,usr.opponent)
if(NS in oview(0,usr.opponent))
else
goto loop
sleep(3)
del NS
LPupdate(usr.table)
else
usr.target="get one"
usr.currentcard=src
usr.StepUpdate("Select Target")
return
if(choice=="Flip")
if(src.stance!="Face Down")
usr<<"You can only flip face down monsters"
return
if(src.justsummoned=="Yes")
usr<<"You cannot Flip a monster card on the turn it is summoned"
return
Flip(usr,src)
return
if(choice=="Turn")
if(src.stance=="Face Down")
usr<<"You cannot turn Face Down monster cards"
return
if(src.justsummoned=="Yes")
usr<<"You cannot Turn a monster card on the turn it is summoned"
return
if(src.canturn!="Yes")
usr<<"You can only Turn a monster card once per turn"
return
if(src.stance=="Defense")
src.canturn="No"
src.stance="Attack"
src.dir=usr.dir
return
if(src.stance=="Attack")
src.canturn="No"
src.stance="Defense"
src.dir=NORTH
return
if(choice=="Summon")
if(usr.summoned=="Yes")
usr<<"You can only Normal Summon 1 monster per turn"
return
usr.summoned="Yes"
if(src.level>4)
if(src.level<=10)
usr.needed=3
if(src.level<=8)
usr.needed=2
if(src.level<=6)
usr.needed=1
switch(alert("[src] requires [usr.needed] tributes to Summon","Summon","Summon","Cancel"))
if("Cancel")
usr.summoned="No"
return
usr.tributes=0
usr.tributelist=new/list()
usr.target="tribute"
usr.currentcard=src
usr.StepUpdate("Select Tribute")
return
NormalSummon(usr,src)
return
if(choice=="Check")
if(src.stance!="Face Down"||src.owner==usr)
var/text2show="([src.level]) [src.icon_state]\n[src.attr] - [src.subtype]\n[src.atk]/[src.def]\nCard Type: [src.cardtype]\nCard Number: [src.cardnum]\nDescription: [src.desc]"
alert("[text2show]","Card Info")
else
usr<<"You cannot view other players face down cards"
return
if(choice=="Look")
if(src.stance!="Face Down"||src.owner==usr)
var/text2show={"





([src.level])[src.icon_state]

[src.attr] - [src.subtype]

[src.atk]/[src.def]

Card Type: [src.cardtype]

Card Number: [src.cardnum]

Description: [src.desc]
"}
usr<<browse("[text2show]","window=Card Information;size=250x300")
else
usr<<"You cannot view other players face down cards"
return


obj
proc
NormalSummon(var/mob/U,var/obj/S)
usr=U
src=S
switch(input("Which position would you like to summon [src] in?","Summon Monster")in list("Attack","Defense","Face Down","Cancel"))
if("Cancel")
usr.summoned="No"
return
if("Attack")
src:stance="Attack"
src.dir=usr.dir
CardInfo(src)
if("Defense")
src:stance="Defense"
src.dir=NORTH
CardInfo(src)
if("Face Down")
src:stance="Face Down"
src.dir=NORTH
src.name="Face Down"
src.icon='BasicCards.dmi'
usr.monsters+=src
usr.MonsterPlacer(usr,src)
usr.hand-=src
src:attacked="No"
src:justsummoned="Yes"
CardNumUpdate(usr)

obj/proc/Tribute(var/mob/M,var/obj/S)
usr=M
src=S
for(var/obj/O in usr.tributelist)
usr.monsters-=O
usr.graveyard+=O
O.loc=usr
usr.tributelist=new/list()
NormalSummon(usr,src)

obj/card/proc
Attack(var/mob/U,var/obj/S)
usr=U
src=S
usr.PhaseUpdate(usr.phase)
var/obj/T=usr.target
var/obj/NS=new/obj/sword()
NS.dir=src.dir
NS.loc=src.loc
loop
sleep(3)
step_towards(NS,T)
if(NS in oview(0,T))
else
goto loop
sleep(3)
del NS
src.attacked="Yes"
src.canturn="No"
var/against
if(T:stance=="Attack")
against=T:atk
else
against=T:def
var/damage=src:atk-against
AttackFlip(T)
if(damage<0)
if(T:stance=="Attack")
usr.monsters-=src
src:owner:graveyard+=src
src:owner:GraveUpdate()
src.loc=usr
usr.lp+=damage
if(damage>0)
if(T:stance=="Attack")
T:owner:lp-=damage
T:owner:monsters-=T
T:owner:graveyard+=T
T:owner:GraveUpdate()
T:loc=T:owner
if(damage==0)
if(T:stance=="Attack")
T:owner:monsters-=T
T:owner:graveyard+=T
T:owner:GraveUpdate()
T:loc=T:owner
usr.monsters-=src
src:owner:graveyard+=src
src:owner:GraveUpdate()
src.loc=usr
usr.target=null
LPupdate(usr.table)
return

proc/Flip(var/mob/M,var/obj/O)
usr=M
if(O:stance=="Face Down")
CardInfo(O)
O:canturn="No"
O:name=O:icon_state
if(O:cardtype=="Monster")
O.icon='monsters.dmi'
else
O.icon='effects.dmi'
O:stance="Attack"
O.dir=usr.dir
if(O:effecttime=="Flipped")
O:EffectRun(usr)
sleep(10)

proc/AttackFlip(var/obj/O)
if(O:stance=="Face Down")
CardInfo(O)
O:name=O:icon_state
if(O:cardtype=="Monster")
O.icon='monsters.dmi'
else
O.icon='effects.dmi'
O:stance="Defense"
if(O:effecttime=="Flipped")
O:EffectRun(usr)
sleep(10)

mob/proc
MonsterPlacer(var/mob/M,var/obj/O)
usr=M
src=O
var/predir=O.dir
src.loc=get_step(usr,usr.dir)
step(src,usr.dir)
var/tempx=src.x
src.loc=usr.loc
var/newy=2
reloc
for(var/obj/X in locate(tempx,usr.y+newy,src.z))
newy-=1
goto reloc
src.loc=locate(tempx,usr.y+newy,usr.z)
O.dir=predir</3>
</0></<browse></5>
obj
card
proc
MonClick(var/mob/U,var/obj/S)
src=S
usr=U
if(src!=null)
var/list/choicelist=new/list()
if(usr.isturn=="Yes")
if(src in oview())
if(usr.target=="get one")
if(src:owner!=usr)
usr.target=src
var/text="Attack [src] with [usr.currentcard]?"
if(src.stance=="Face Down")
text="Attack Face Down Card with [usr.currentcard]?"
switch(alert("[text]","Attack Target","Yes","No"))
if("Yes")
if(src.effecttime=="IsAttacked")
var/returned=src:EffectRun(usr)
if(returned=="Stop")
return
src.Attack(usr,usr.currentcard)
return
if(usr.target=="tribute")
if(src.owner==usr)
if(src in usr.tributelist)
usr<<"You have Already Selected this Monster to be Tributed!"
else
switch(alert("Tribute [src] to summon [usr.currentcard]?","Tribute Monster","Yes","No"))
if("Yes")
usr.tributelist+=src
usr.tributes+=1
if(usr.tributes>=usr.needed)
usr.target=null
Tribute(usr,usr.currentcard)
usr.GraveUpdate()
usr.PhaseUpdate(usr.phase)
return
if(src.owner==usr)
if((usr.phase=="Battle"&&src.attacked=="No")&&usr.table:turn>1)
choicelist+="Attack"
else
if((src.canturn=="Yes"&&src.justsummoned=="No")&&src.stance!="Face Down")
choicelist+="Turn"
if(src.justsummoned=="No"&&src.stance=="Face Down")
choicelist+="Flip"
if(src in usr.hand)
if(usr.summoned=="No")
var/counter=0
for(var/obj/O in usr.monsters)
counter+=1
if(src.level<=4)
if(counter<5)
choicelist+="Summon"
if((src.level==5||src.level==6)&&counter>=1)
choicelist+="Summon"
if((src.level==7||src.level==8)&&counter>=2)
choicelist+="Summon"
if((src.level==9||src.level==10)&&counter>=3)
choicelist+="Summon"
var/counter=0
for(var/obj/O in usr.hand)
counter+=1
if(usr.phase=="Main Phase 2"&&counter>6)
choicelist+="Discard"
if(usr.dueling=="No")
if(src in usr.deck)
choicelist+="Remove from Deck"
if(src in usr.cards)
choicelist+="Add to Deck"
choicelist+="Look"
choicelist+="Check"
choicelist+="Cancel"
if(src.owner!=usr&&src.stance=="Face Down")
usr<<"You cannot view other players Face Down cards"
return
var/choice=input("([src.level]) [src.icon_state] \n[src.atk]/[src.def]","Make Selection")as anything in choicelist
if(choice=="Cancel"||choice==null)
return
if(choice=="Add to Deck")
var/counter=0
for(var/obj/X in usr.deck)
if(X.name==src.name)
counter+=1
if(counter<3)
usr.cards-=src
usr.justgot-=src
usr.deck+=src
else
usr<<"You can only have 3 of each card in your deck!"
return
if(choice=="Remove from Deck")
usr.deck-=src
usr.cards+=src
return
if(choice=="Discard")
usr.hand-=src
usr.graveyard+=src
CardNumUpdate(usr)
usr.GraveUpdate()
return
if(choice=="Attack")
if(src.stance!="Attack")
usr<<"Monsters can only attack when they are in the Attack position"
return
var/counter=0
for(var/obj/O in usr.opponent:monsters)
counter+=1
if(counter<=0)
switch(alert("Directly attack [usr.opponent]'s LP?","Attack","Yes","No"))
if("Yes")
src.attacked="Yes"
usr.target=null
usr.opponent:lp-=src.atk
var/obj/NS=new/obj/sword()
NS.dir=src.dir
NS.loc=src.loc
loop
sleep(3)
step_towards(NS,usr.opponent)
if(NS in oview(0,usr.opponent))
else
goto loop
sleep(3)
del NS
LPupdate(usr.table)
else
usr.target="get one"
usr.currentcard=src
usr.StepUpdate("Select Target")
return
if(choice=="Flip")
if(src.stance!="Face Down")
usr<<"You can only flip face down monsters"
return
if(src.justsummoned=="Yes")
usr<<"You cannot Flip a monster card on the turn it is summoned"
return
Flip(usr,src)
return
if(choice=="Turn")
if(src.stance=="Face Down")
usr<<"You cannot turn Face Down monster cards"
return
if(src.justsummoned=="Yes")
usr<<"You cannot Turn a monster card on the turn it is summoned"
return
if(src.canturn!="Yes")
usr<<"You can only Turn a monster card once per turn"
return
if(src.stance=="Defense")
src.canturn="No"
src.stance="Attack"
src.dir=usr.dir
return
if(src.stance=="Attack")
src.canturn="No"
src.stance="Defense"
src.dir=NORTH
return
if(choice=="Summon")
if(usr.summoned=="Yes")
usr<<"You can only Normal Summon 1 monster per turn"
return
usr.summoned="Yes"
if(src.level>4)
if(src.level<=10)
usr.needed=3
if(src.level<=8)
usr.needed=2
if(src.level<=6)
usr.needed=1
switch(alert("[src] requires [usr.needed] tributes to Summon","Summon","Summon","Cancel"))
if("Cancel")
usr.summoned="No"
return
usr.tributes=0
usr.tributelist=new/list()
usr.target="tribute"
usr.currentcard=src
usr.StepUpdate("Select Tribute")
return
NormalSummon(usr,src)
return
if(choice=="Check")
if(src.stance!="Face Down"||src.owner==usr)
var/text2show="([src.level]) [src.icon_state]\n[src.attr] - [src.subtype]\n[src.atk]/[src.def]\nCard Type: [src.cardtype]\nCard Number: [src.cardnum]\nDescription: [src.desc]"
alert("[text2show]","Card Info")
else
usr<<"You cannot view other players face down cards"
return
if(choice=="Look")
if(src.stance!="Face Down"||src.owner==usr)
var/text2show={"
<html>
<title>Card Information</title>
<body bgcolor=CCCC66>
<center></center>

(
[src.level])[src.icon_state]

[src.attr] - [src.subtype]

[src.atk]/[src.def]

Card Type:
[src.cardtype]

Card Number:
[src.cardnum]

Description:
[src.desc]
"}

usr<<browse("[text2show]","window=Card Information;size=250x300")
else
usr<<"You cannot view other players face down cards"
return


obj
proc
NormalSummon(var/mob/U,var/obj/S)
usr=U
src=S
switch(input("Which position would you like to summon [src] in?","Summon Monster")in list("Attack","Defense","Face Down","Cancel"))
if("Cancel")
usr.summoned="No"
return
if("Attack")
src:stance="Attack"
src.dir=usr.dir
CardInfo(src)
if("Defense")
src:stance="Defense"
src.dir=NORTH
CardInfo(src)
if("Face Down")
src:stance="Face Down"
src.dir=NORTH
src.name="Face Down"
src.icon='BasicCards.dmi'
usr.monsters+=src
usr.MonsterPlacer(usr,src)
usr.hand-=src
src:attacked="No"
src:justsummoned="Yes"
CardNumUpdate(usr)

obj/proc/Tribute(var/mob/M,var/obj/S)
usr=M
src=S
for(var/obj/O in usr.tributelist)
usr.monsters-=O
usr.graveyard+=O
O.loc=usr
usr.tributelist=new/list()
NormalSummon(usr,src)

obj/card/proc
Attack(var/mob/U,var/obj/S)
usr=U
src=S
usr.PhaseUpdate(usr.phase)
var/obj/T=usr.target
var/obj/NS=new/obj/sword()
NS.dir=src.dir
NS.loc=src.loc
loop
sleep(3)
step_towards(NS,T)
if(NS in oview(0,T))
else
goto loop
sleep(3)
del NS
src.attacked="Yes"
src.canturn="No"
var/against
if(T:stance=="Attack")
against=T:atk
else
against=T:def
var/damage=src:atk-against
AttackFlip(T)
if(damage<0)
if(T:stance=="Attack")
usr.monsters-=src
src:owner:graveyard+=src
src:owner:GraveUpdate()
src.loc=usr
usr.lp+=damage
if(damage>0)
if(T:stance=="Attack")
T:owner:lp-=damage
T:owner:monsters-=T
T:owner:graveyard+=T
T:owner:GraveUpdate()
T:loc=T:owner
if(damage==0)
if(T:stance=="Attack")
T:owner:monsters-=T
T:owner:graveyard+=T
T:owner:GraveUpdate()
T:loc=T:owner
usr.monsters-=src
src:owner:graveyard+=src
src:owner:GraveUpdate()
src.loc=usr
usr.target=null
LPupdate(usr.table)
return

proc/Flip(var/mob/M,var/obj/O)
usr=M
if(O:stance=="Face Down")
CardInfo(O)
O:canturn="No"
O:name=O:icon_state
if(O:cardtype=="Monster")
O.icon='monsters.dmi'
else
O.icon='effects.dmi'
O:stance="Attack"
O.dir=usr.dir
if(O:effecttime=="Flipped")
O:EffectRun(usr)
sleep(10)

proc/AttackFlip(var/obj/O)
if(O:stance=="Face Down")
CardInfo(O)
O:name=O:icon_state
if(O:cardtype=="Monster")
O.icon='monsters.dmi'
else
O.icon='effects.dmi'
O:stance="Defense"
if(O:effecttime=="Flipped")
O:EffectRun(usr)
sleep(10)

mob/proc
MonsterPlacer(var/mob/M,var/obj/O)
usr=M
src=O
var/predir=O.dir
src.loc=get_step(usr,usr.dir)
step(src,usr.dir)
var/tempx=src.x
src.loc=usr.loc
var/newy=2
reloc
for(var/obj/X in locate(tempx,usr.y+newy,src.z))
newy-=1
goto reloc
src.loc=locate(tempx,usr.y+newy,usr.z)
O.dir=predir