In php if I have?
$spaceship1 = 1;
$spaceship2 = 2;
$spaceship3 = 3;
$spaceship4 = 4;
$ufo1 = 1;
$ufo2 = 2;
$ufo3 = 3;
$ufo4 = 4;
Now if $spaceship2 does damage against $ufo3 and does no damage against $ufo1, $ufo2, $ufo4 while all $ufo attack back on all spaceship.
Am I making it to complicated?
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Am I making it to complicated?
What are these numbers? What are you trying to do? You will need to give us a lot more information before we can help you.
The indelible lord of tl;dr
Re: Am I making it to complicated?
Yeah, sorry that was not much info.
would be like.
$playerspaceship1 = 1 * $playerinfo3['spaceship1'];
If I have 4 different types of spaceships and attack 4 different types of ufo's. I would like 1 spaceship to be strong against ufo while the other 3 spaceships have little or no damage to the ufo's. Those ufo's would also attack back when being attacked, Those ufo's would all be able to attack back at all spaceships. Even though only 1 of those spaceships would do damage all those spaceships would be attacking.
I would have to attack with all 4 spaceships though. The defender would have no choice than to defend with all 4 ufo's.
I have a lot to learn.
would be like.
$playerspaceship1 = 1 * $playerinfo3['spaceship1'];
If I have 4 different types of spaceships and attack 4 different types of ufo's. I would like 1 spaceship to be strong against ufo while the other 3 spaceships have little or no damage to the ufo's. Those ufo's would also attack back when being attacked, Those ufo's would all be able to attack back at all spaceships. Even though only 1 of those spaceships would do damage all those spaceships would be attacking.
I would have to attack with all 4 spaceships though. The defender would have no choice than to defend with all 4 ufo's.
I have a lot to learn.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Am I making it to complicated?
You could store the spaceships in an array to help keep the code clear and to prevent repeating the same kind of code over and over. That way, say you want to alter the value of each spaceship, instead of doing something like this:
You could do something more like this:
Code: Select all
$spaceship1 = $spaceship1 + 1;
$spaceship2 = $spaceship2 + 1;
$spaceship3 = $spaceship3 + 1;
$spaceship4 = $spaceship4 + 1;Code: Select all
foreach ($spaceship as $unit) {
$unit += 1;
}
If you want to explain a bit more about your game, I could try to help you with more of the logic. Are these same spaceships always on the board? If they are, you could hardcode the logic for which spaceship is tougher against which UFO. If they are not, it would be a small bit more complicated.The indelible lord of tl;dr
Re: Am I making it to complicated?
@Jack
I don't have a game so was just trying to learn some things that I would want to do. I have an idea about a space wargame, not that I have seen here though. I am just working on the tutorial and trying to build on that.
I changed some things up though. Have 4 spaceships, 4 ufos, 4 spacecraft, 4 alien ships.
spaceship1 is good against ufos but not good against spaceships, spacecraft or alien ships.
spaceship2 is good against spacecraft but not good against spaceship, ufo or alien ships.
Still want spaceship1 to do damage to the others but more damage to ufos.
different scenarios for different spaceships and different ufos and the other ships.
Players will be able to decide which ships, ufos, crafts they may want.
I don't have a game so was just trying to learn some things that I would want to do. I have an idea about a space wargame, not that I have seen here though. I am just working on the tutorial and trying to build on that.
I changed some things up though. Have 4 spaceships, 4 ufos, 4 spacecraft, 4 alien ships.
spaceship1 is good against ufos but not good against spaceships, spacecraft or alien ships.
spaceship2 is good against spacecraft but not good against spaceship, ufo or alien ships.
Still want spaceship1 to do damage to the others but more damage to ufos.
different scenarios for different spaceships and different ufos and the other ships.
Players will be able to decide which ships, ufos, crafts they may want.