# SWDB

# \Unit

A Unit.

Represents an object from the table 'unit'.

## Summary

Methods
Properties
Constants
__construct()
check_storage()
load_teams()
load_runes()
are_skills_maxed()
$db
$uid
$id
$building
$unit
$stars
$level
$hp
$attack
$defense
$speed
$crit_rate
$crit_damage
$resistance
$accuracy
$experience
$exp_gained
$exp_gain_rate
$costume
$source
$create_time
$homunculus_name
$lock
$rune_hp
$rune_attack
$rune_defense
$rune_speed
$rune_crit_rate
$rune_crit_damage
$rune_resistance
$rune_accuracy
$avg_rune_efficiency
$rune
$teams
$skill_levels
$experience_level
$experience_level_up
$in_storage
$title
No constants found
No protected methods found
No protected properties found
N/A
sum_rune_stat()
No private properties found
N/A

File
  application/entity/Unit.php
Package
  Default
Class hierarchy
  \Entity
  \Unit

## Tags

category | Entity

## Properties

### $db

    $db : resource

#### Type

resource — Database connection.

#

Inherited from
  \Entity

## Tags

None found

### $uid

    $uid : integer

#### Type

integer — User ID.

#

## Tags

None found

### $id

    $id : integer

#### Type

integer — Unit ID.

#

## Tags

None found

### $building

    $building : \Building

#### Type

\Building — Building the unit is on.

#

## Tags

None found

### $unit

    $unit : \K_Unit

#### Type

\K_Unit — Base unit.

#

## Tags

None found

### $stars

    $stars : integer

#### Type

integer — Unit stars.

#

## Tags

None found

### $level

    $level : integer

#### Type

integer — Unit level.

#

## Tags

None found

### $hp

    $hp : integer

#### Type

integer — Unit base HP stat.

#

## Tags

None found

### $attack

    $attack : integer

#### Type

integer — Unit base ATK stat.

#

## Tags

None found

### $defense

    $defense : integer

#### Type

integer — Unit base DEF stat.

#

## Tags

None found

### $speed

    $speed : integer

#### Type

integer — Unit base SPD stat.

#

## Tags

None found

### $crit_rate

    $crit_rate : integer

#### Type

integer — Unit base CRR stat.

#

## Tags

None found

### $crit_damage

    $crit_damage : integer

#### Type

integer — Unit base CRD stat.

#

## Tags

None found

### $resistance

    $resistance : integer

#### Type

integer — Unit base RES stat.

#

## Tags

None found

### $accuracy

    $accuracy : integer

#### Type

integer — Unit base ACC stat.

#

## Tags

None found

### $experience

    $experience : integer

#### Type

integer — Total gained experience.

#

## Tags

None found

### $exp_gained

    $exp_gained : integer

#### Type

integer — Total gained experience in its current level.

#

## Tags

None found

### $exp_gain_rate

    $exp_gain_rate : integer

#### Type

integer — Experience / hour in the current building.

#

## Tags

None found

### $costume

    $costume : integer

#### Type

integer — Equipped transmogification.

#

## Tags

None found

### $source

    $source : \K_Source

#### Type

\K_Source — Source the unit was aquired from.

#

## Tags

None found

### $create_time

    $create_time : \Datetime

#### Type

\Datetime — Time the unit was obtained.

#

## Tags

None found

### $homunculus_name

    $homunculus_name : string

#### Type

string — Indicates the Homunculus name

#

## Tags

None found

### $lock

    $lock : boolean

#### Type

boolean — Indicates if the monster is locked.

#

## Tags

None found

### $rune_hp

    $rune_hp : integer

#### Type

integer — Unit rune HP stat.

#

## Tags

None found

### $rune_attack

    $rune_attack : integer

#### Type

integer — Unit rune ATK stat.

#

## Tags

None found

### $rune_defense

    $rune_defense : integer

#### Type

integer — Unit rune DEF stat.

#

## Tags

None found

### $rune_speed

    $rune_speed : integer

#### Type

integer — Unit rune SPD stat.

#

## Tags

None found

### $rune_crit_rate

    $rune_crit_rate : integer

#### Type

integer — Unit rune CRR stat.

#

## Tags

None found

### $rune_crit_damage

    $rune_crit_damage : integer

#### Type

integer — Unit rune CRD stat.

#

## Tags

None found

### $rune_resistance

    $rune_resistance : integer

#### Type

integer — Unit rune RES stat.

#

## Tags

None found

### $rune_accuracy

    $rune_accuracy : integer

#### Type

integer — Unit rune ACC stat.

#

## Tags

None found

### $avg_rune_efficiency

    $avg_rune_efficiency : float

#### Type

float — Average rune efficiency.

#

## Tags

None found

### $rune

    $rune : array<mixed,\Rune>

#### Type

array<mixed,\Rune> — Equiped Runes.

#

## Tags

None found

### $teams

    $teams : array<mixed,\Team>

#### Type

array<mixed,\Team> — The Teamss the unit is on.

#

## Tags

None found

### $skill_levels

    $skill_levels : array<mixed,integer>

#### Type

array<mixed,integer> — Array with the levels of the skills, in orer.

#

## Tags

None found

### $experience_level

    $experience_level : integer

#### Type

integer — Total experience required for the current level.

#

## Tags

None found

### $experience_level_up

    $experience_level_up : integer

#### Type

integer — Experience required to level up.

#

## Tags

None found

### $in_storage

    $in_storage : integer

#### Type

integer — Indcates if the unit is in storage.

#

## Tags

None found

### $title

    $title : string

#### Type

string — Unit title. If Homunculus,it will be it's name. If awakened, it will be the awakened from name. If unawakened, it will be <element> <name>.

#

## Tags

None found

## Methods

### __construct()

    __construct(resource  $db, integer  $id, boolean  $complete = true)

Constructor.

Searches the database and retrieves the information about the monster, populating it and it's items.

#### Parameters

resource | $db | Connection to the database.
integer | $id | Monster identifier.
boolean | $complete | If false, query only monster and k_monster.

#

## Tags

global | int Player ID.

### check_storage()

    check_storage()

Checks if the monster is in storage and sets {@see $in_storage} to true or false.

#

## Tags

global | int Player ID.

### load_teams()

    load_teams()

Loads the {@see teams} array, with the teams the unit is on.

#

## Tags

global | int Player ID.

### load_runes()

    load_runes()

Loads the information about the equiped runes.

It is autoatically called at construction time if the $complete parameter is true (by default). No point in calling it twice.

#

## Tags

None found

### are_skills_maxed()

    are_skills_maxed() : boolean

Checks if the unit skills are completly maxed.

#### Returns

boolean —

True if all skills maxed, false otherwise.

#

## Tags

None found

### sum_rune_stat()

    sum_rune_stat(string  $stat, integer  $value)

Calculates the stat increase by a rune property.

#### Parameters

string | $stat | Stat type.
integer | $value | Stat increase value.

#

## Tags

None found

### Unit.php