What is this doing on a Perl site?

This site is dedicated to learning, not getting other people to do your work. We'll help you learn, we won't generally write your own script for you.

I'll make the rest of my reply based on the assumption that you want to learn.

First of all the question is unclear. What exactly should a brawling script do? Go through a single hit? Or have 2 opponents duel to the death? (Possibly with random comments from, "XXX mercilessly attacks thin air." to "XXX delivers a crushing blow to the chest, doing 34 HP damage. A bloody smear marks YYY's passing.")

Either way your problem is probably that you're trying to bite off too much at once. There are two common strategies to use in this case - top down or bottom up.

For bottom up, you'd write a function that does something simple and necessary, then test it. For instance figures out what the results of a single blow are. Try running that function and see if it works. And another to update a character's stats after the blow. Try having one monster hit another one and see whether the other monster accumulates damage. Then continue to layer one task on top of another until you've got the whole thing. For instance next might be a function to track who strikes whom in what order. And so on.

For top down you'd look at the overall problem and try to break it into pieces. For instance you might say that a brawl breaks into attacks. So first you need to write a control loop that figures out who attacks whom in what order. (Be sure that this loop can tell if someone is dead!) And then try to write code for how to handle a single attack.

Both approaches work (and pros work them together). Either approach gives you a way to avoid getting stuck.

Remember. Work in small simple pieces. Stop often to see that you're still on a track to succeed.


In reply to Re: (OT) Brawling Javascript by tilly
in thread (OT) Brawling Javascript by mariol

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.