File: unit.h

package info (click to toggle)
ogamesim 20130107-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 944 kB
  • sloc: ansic: 1,621; perl: 1,041; makefile: 161; javascript: 97; sh: 21
file content (66 lines) | stat: -rw-r--r-- 2,589 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
Copyright (C) by Dmitry E. Oboukhov 2006, 2007

  This package is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  
  This package is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with this package; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
*/
#ifndef __UNIT__H__
#define __UNIT__H__

// структура, описывающая скорострел
typedef struct
{
  int id;             // идентификатор против кого (в info) скорострел
  int rf;             // игровое значение скорострела
  double chance;      // вычисленный шанс на сл. выстрел
} rapidfire;

// массив структур информации о юнитах
// (читается из конфиг-файла)
// id - в остальных структурах - индекс в этом массиве
typedef struct
{
  char name[64];
  int shield, structure, attack, capacity;
  int metal, crystal, deut;   // стоимость юнита

  struct
  {
    unsigned int ground:1;            // 1 = наземное сооружение
    unsigned int large_chargo:1;      // 1 = большой транспорт
    unsigned int small_chargo:1;      // 1 = малый транспорт
    unsigned int recycler:1;          // 1 = переработчик
  } flags;
  int rapid;
} unit_info;


// структура, описывающая юнит
typedef struct
{
  int id;                       // юнита в таблице units
  int attack, shield, armory;   // параметры юнита
  struct
  {
    int shield, armory;
  } max;
} unit;

// производит симуляцию одного юнита (против одного юнита)
// возвращает истину если можно еще раз атаковать (скорострел)
int attack_unit(const unit * attacker, unit * defender);

// создает юнит скорректированный под параметры игрока
unit create_unit(int id, int gattack, int gshield, int garmory);
#endif