Base code
This commit is contained in:
		
							parent
							
								
									fefc90006f
								
							
						
					
					
						commit
						92dd81cdaa
					
				| 
						 | 
				
			
			@ -1,8 +1,53 @@
 | 
			
		|||
#include <iostream>
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
using namespace std;
 | 
			
		||||
 | 
			
		||||
struct Params {
 | 
			
		||||
    int life = 3;
 | 
			
		||||
    int movement = 4;
 | 
			
		||||
    int pos[2];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class Enemy: protected Params {
 | 
			
		||||
    virtual void move() {};
 | 
			
		||||
    friend void killAi(Enemy);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template <class TT>
 | 
			
		||||
 | 
			
		||||
class Palladin : public Enemy {
 | 
			
		||||
    TT stamina;
 | 
			
		||||
    string weapon = "sword";
 | 
			
		||||
    int mana = 10;
 | 
			
		||||
public:
 | 
			
		||||
    void move(int x, int y) {
 | 
			
		||||
        if (movement > x && movement > y) {
 | 
			
		||||
            pos[0] = x;
 | 
			
		||||
            pos[1] = y;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
void killAi(Enemy e) {
 | 
			
		||||
    e.life = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <class TTTT>
 | 
			
		||||
 | 
			
		||||
TTTT upgradeAi(TTTT e) {
 | 
			
		||||
    return e;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    cout << "Hello World!\n";
 | 
			
		||||
    Palladin<vector<int>> jerzy;
 | 
			
		||||
    Enemy kretoszczur;
 | 
			
		||||
    jerzy.move(1, 1);
 | 
			
		||||
    killAi(jerzy);
 | 
			
		||||
    killAi(kretoszczur);
 | 
			
		||||
 | 
			
		||||
    upgradeAi(jerzy);
 | 
			
		||||
    upgradeAi(kretoszczur);
 | 
			
		||||
    upgradeAi("kolonia");
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue