///////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 The 8-Bit Bunch. Licensed under the Apache License, Version 1.1 
// (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at <http://www.apache.org/licenses/LICENSE-1.1>.
// Unless required by applicable law or agreed to in writing, software distributed under 
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 
// ANY KIND, either express or implied. See the License for the specific language 
// governing permissions and limitations under the License.
///////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////
// Structures for the heap

const TYPE_GLOBAL = $80
struc Global
  byte t_type
  word p_players
  word p_enemyGroups
  word p_combatFirst
  word p_encounterZones

  // Map position
  byte b_mapIs3D
  byte b_mapNum
  word w_mapX
  word w_mapY
  byte b_mapDir
end

const PLAYER_FLAG_NPC  = $01

const TYPE_PLAYER = $81
struc Player
  byte t_type
  word p_nextObj
  word s_name
  byte b_combatOrder
  word p_combatNext
  word w_health

  // Innate attributes
  byte b_intelligence
  byte b_strength
  byte b_agility
  byte b_bravery
  byte b_stamina
  byte b_charisma
  byte b_spirit

  // Calculated attributes
  byte b_armor

  // Basic skills
  byte b_aiming
  byte b_dodging
  byte b_wilderness

  // Status
  word w_maxHealth
  byte b_combatChoice
  byte b_playerFlags

  // Lists
  word p_skills  // list:Modifier
  word p_items   // list:Item
  word p_buffs   // list:Effect
  word p_debuffs // list:Effect
end

// Combat skills, weapon modifiers, etc.
const TYPE_MODIFIER = $82
struc Modifier
  byte t_type
  word p_nextObj
  byte b_modKind
  byte b_modValue
end

// Buffs and debuffs, that last until a specified time
const TYPE_EFFECT = $83
struc Effect
  byte t_type
  word p_nextObj
  byte b_modKind
  byte b_modValue
  word s_effectDescrip
  word w_endTurn
end

const TYPE_ITEM = $84
struc Item
  byte t_type
  word p_nextObj
  word s_name
  byte b_itemKind
  word w_cost
  word p_modifiers  // list:modifier
end

const WEAPON_FLAG_SINGLE_USE  = $01
const WEAPON_FLAG_WHOLE_GROUP = $02

const TYPE_WEAPON = $85
struc Weapon
  // Item properties
  byte t_type
  word p_nextObj
  word s_name
  byte b_itemKind
  word w_cost
  word p_modifiers  // list:modifier
  // Usables properties
  byte b_maxUses
  byte b_curUses
  // Weapon properties
  byte b_weaponFlags    // WEAPON_FLAG_* above
  byte b_ammoKind
  byte b_clipSize
  byte b_clipCurrent
  word r_meleeDmg       // 3 hex digits: num dice, die size, add. E.g. $361 = 3d6+1
  word r_projectileDmg  // ditto
  byte ba_attacks[3]    // each is: 0=none, 1=single, 2=double, 3+ = multi-shot
  byte b_weaponRange
  word s_combatText
end

const TYPE_ARMOR = $86
struc Armor
  // General item properties
  byte t_type
  word p_nextObj
  word s_name
  byte b_itemKind
  word w_cost
  word p_modifiers  // list:modifier
  // Usables properties
  byte b_maxUses
  byte b_curUses
  // Armor properties
  byte b_armorValue
end

// Countable things, e.g. ammo and pelts
const TYPE_STUFF = $87
struc Stuff
  // General item properties
  byte t_type
  word p_nextObj
  word s_name
  byte b_itemKind
  word w_cost
  // Stuff properties
  word w_count
  word w_maxCount
end

const TYPE_ENEMY = $88
struc Enemy
  byte t_type
  word p_nextObj
  word s_name
  byte b_combatOrder
  word p_combatNext
  word w_health

  byte b_image
  byte b_hitBonus
  byte b_attackType   // 1=melee, 2=projectile
  word s_attackText
  byte b_enemyAttackRange
  byte b_chanceToHit
  word r_enemyDmg     // 3 hex digits: num dice, die size, add. E.g. $361 = 3d6+1
  word r_groupSize    // number encountered, as 3 hex digits for dice
end

const TYPE_ENEMY_GROUP = $89
struc EnemyGroup
  byte t_type
  word p_nextObj
  word p_enemies
  byte b_enemyGroupRange
end

const TYPE_ENCOUNTER_ZONE = $8A
struc EncounterZone
  byte t_type
  word p_nextObj
  word s_name   // enemy code
  word w_encX
  word w_encY
  word w_encMaxDist
  word w_encChance
end

// Weapon kinds
const KIND_BOW          = 1;
const KIND_BLADE        = 2;
const KIND_EXPLOSIVE    = 3;
const KIND_HANDGUN      = 4;
const KIND_HAND_TO_HAND = 5;
const KIND_RIFLE        = 6;
const KIND_THROWING     = 7;
// Skill kinds
const KIND_MINING       = 8;
const KIND_NATIVE_BOND  = 9;
const KIND_PYRE_WARE    = 10
// Ammo kinds
const KIND_BULLET       = 11
const KIND_ARROW        = 12
const KIND_BUCK         = 13
const KIND_QUARREL      = 14
// Armor kinds
const KIND_SHOES        = 15
const KIND_COAT         = 16
const KIND_HAT          = 17
const KIND_PANTS        = 18
const KIND_SHIRT        = 19
const KIND_GLOVES       = 20
const KIND_SHIELD       = 21
