ID:148222
 
Ok in my .hack//sign card game there is an attack button when you are dueling.When you click on it it says you atked but you do no dmg.Here is the code.

mob/Hidden/verb/
Attack(mob/M in oview(1))
set category = "Duel"
if(usr.Turn == 0)
alert("It's not your turn")
else
usr.Field = input("What card do you want to attack with?") in FieldCards
switch (Field)
if("Bear")
usr.atk += 500

usr.Opp = input("What card do you want to attack?") in M.FieldCards


if(usr.atk <= M.atk)
usr.Life -= M.atk
var/some = pick(src.FieldCards)
usr.DiscardPile.Add(some)
usr.FieldCards.Remove(some)
usr.EndDuel()
M.EndDuel()
M.atk = 0
M.Draw+=1
usr.Draw+=1
M<<"[usr] attacks you."
usr<<"You attacked [M]."
else
M.Life -= usr.atk
var/some = pick(src.FieldCards)
M.DiscardPile.Add(some)
M.FieldCards.Remove(some)
M.EndDuel()
usr.EndDuel()
M.atk = 0
M.Draw+=1
usr.Draw+=1
M<<"[usr] attacks you."
usr<<"You attacked [M]."

can someone tell me what the problem is?
Try using usr.Opp instead of M. M is any mob, usr.Opp seems to be an exact mob.
In response to Cra Zee Coder
Well i figured out were the problem is.See the code will atk but the choose a card won't work.Se i have a list for the field and the boj that go in it similar to buzzy's yugioh game and i can't get them to add the atk power to me, so that is the problem.
In response to FinalFantasyFreak
FinalFantasyFreak wrote:
Well i figured out were the problem is.See the code will atk but the choose a card won't work.Se i have a list for the field and the boj that go in it similar to buzzy's yugioh game and i can't get them to add the atk power to me, so that is the problem.

I got a tip for ya, instead of adding attack to to usr the way you do. Create a new var for all the cards called power or something like that. and instead change the 2 lines after switch to...

<code>switch(Field) if(Field) usr.atk += Field.power</code>

That should keep you from doing a new if() check for each creature. Since Field is a card and every card has power it will find the power of that card and add it.

Resonating Light
In response to Resonating_Light
It kept saying it need the var for power when i made obj/var/power = 0
In response to FinalFantasyFreak
FinalFantasyFreak wrote:
It kept saying it need the var for power when i made obj/var/power = 0

Oh! sorry about that. Just take that stuff out of there. I hadn't realized that you were checking for a name and not a type path so it wouldn't work.... Unless you were to change the card list to type paths instead of names. In other words, replace
"Bear"
with
/obj/card/bear
.If you don't feel like making a new obj for every card you can just take out the original things I had told you.

Resonating Light
In response to Resonating_Light
I found one, that you