Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program in c++ to simulate a conflict between two groups of hereos.(Link

ID: 671661 • Letter: W

Question

Write a program in c++ to simulate a conflict between two groups of hereos.(Linked List)

1. The simulation will consist of a list of at least one instance of class Super for each side.

2. Each instance of class Super will contain the following information:

a. ID

b. X,Y,Z location in space

c. Physical attributes(strenght, endurance, agility, speed)

d. List of powers(p1...pn)

e. List of equipment(e1...en)

f. List of Super * called Target(which might be one or more)

3. A power has the following atrributes:

a. Effect (strength, endurance, agility, speed) is a modifier

i. Example(-10,-20,0,0)

ii. Example(+4,0,+2,0)

b. Duration

c. Type: single or multiple targets

d. Range

4. Equipment has one or more powers

5. A round will consist of a number of attacks between the teams.

6. An attack will consist of a character handing one or more targets an effect.

7. Combat: To-Hit phase followed by a Damage phase

a. To Hit is computed as 50+(atk(speed+agility)-def(speed+agility)) is compared to a random 1 to 100 value with a hit scored with the random is the hit number or less.

b. Damage is computed as

Raw Damage=(50+(atk(strength+speed)-def(agility+endurance)))

Damage=Raw Damage*(100+atk(endurance))/2000

Damage is subtracted from the defenders Endurance score

All powers, equipment and weapons have a set of the attribute (effect) scores.

Development

1. Create two lists of characters, TeamA, TeamB

2. Sort by speed

3. Character with highest speed goes first

a. Choose target by proximity

b. Choose power randomly

c. Move if necessary to use power

d. Attempt to hit

e. If the hit is successful then compute damage

f. Apply damage to targets endurance

4. The next highest speed goes next regardless of team until all characters have had a turn.

Rinse and repeat until one team has all endurance scores reduced to zero.

Explanation / Answer

#include<iostream>
#include <cstdlib> /* srand, rand */
#include <ctime> /* time */
using namespace std;
struct power
{
   int strength,endurance,agility,speed,duration;
  
};
class super
{
   int id,x,y,z;
   power p;
  
   public:
      
       void insert()
       {
           //cout<<"enter id, x,y,z location: ";
       //   cin>>id>>x>>y>>z;
           cout<<"strength, endurance, agility, speed: ";
           cin>>p.strength>>p.endurance>>p.agility>>p.speed;
          
       }
       int sa_add()
       {
           return (p.speed+p.agility);
       }
       int ss_add()
       {
           return (p.speed+p.strength);
       }
       int ae_add()
       {
           return (p.endurance+p.agility);
       }
       int endu()
       {
      
           return p.endurance;
       }
       void modify_endurance(int d)
       {
           p.endurance=p.endurance-d;
       }
  

};

int raw_damage(super atk, super def)
{
           return (50+(atk.sa_add()-def.ae_add()));
}
int damage(super atk, super def)
{
           return raw_damage(atk,def)*(100+(atk.endu()))/2000;
}
int hit(super atk, super def)
{
   return 50+(atk.sa_add()-def.sa_add());
}

void attacker(super atk, super def)
   {
       /*time_t seconds;
       /*
       Get value from system clock and
       place in seconds variable.
      
       time(&seconds);
       /*
       Convert seconds to a unsigned
       integer.
      
       srand((unsigned int) seconds);
       int random=rand()%100;
       int h=hit(atk,def);
       cout<<random<<" "<<h;
       if(h<random)
       { */
           int dam=damage(atk,def);
           cout<<dam;
           def.modify_endurance(dam);
      
      
   }
int main()
{
   super a,b;
   a.insert();
   b.insert();
   int i=0;
   while(i<10)
   {
       if(i%2==0)
           attacker(a,b);
       else
           attacker(b,a);
       if(a.endu()<1)
       {
           cout<<"Team B is winner";
           cout<<" No of attacks= "<<i/2;
           break;
       }
          
       if(b.endu()<1)
       {
           cout<<"Team A is winner";
           cout<<" No of attacks= "<<i/2;
           break;
       }
      
       i++;
      
   }
  
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote