Minase Posted August 18, 2008 Share Posted August 18, 2008 hi again,now im working on my battle script for my game but i don't know how to do this task,know it should be easy but don't have nothing in mind right now what i should google.thanks. $attacker = "Attacker"; $defender = "Defender"; $rounds = rand(5,10); for($r = 1; $r <= $rounds ; $r++){ //the php part needed } $rounds = it define how many rounds users can fight i want first attack to be gived by attacker,and the second by defender,and so on till the rounds end if $rounds = 5 $attacker->Attack; $defender->Attack; $attacker->Attack; $defender->Attack $attacker->Attack; dont know really how to define it.thank you. Link to comment https://forums.phpfreaks.com/topic/120222-solved-php-order/ Share on other sites More sharing options...
Mchl Posted August 18, 2008 Share Posted August 18, 2008 for($r = 1; $r <= $rounds ; $r++){ if ($r % 2 == 0) { $defender->Attack(); } else { $defender->Attack(); } } Link to comment https://forums.phpfreaks.com/topic/120222-solved-php-order/#findComment-619301 Share on other sites More sharing options...
Minase Posted August 18, 2008 Author Share Posted August 18, 2008 thank you Link to comment https://forums.phpfreaks.com/topic/120222-solved-php-order/#findComment-619310 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.