/** * Generate an attachment ID for this robot based on the attachment token * @param string $attachment_token (optional) * @return int */ public function get_attachment_id($attachment_token = 'attachment') { return rpg_attachment::generate_id($this->get_id(), $attachment_token); }
/** * Load new attachment data into the battle object and index by attachment_id * @param rpg_player $this_player * @param rpg_robot $this_robot * @param array $attachment_info * @return bool */ public function add_attachment(rpg_player $this_player, rpg_robot $this_robot, $attachment_info) { if (!isset($attachment_info['attachment_id'])) { return false; } elseif (!isset($attachment_info['attachment_token'])) { return false; } $attachment_id = $attachment_info['attachment_id']; $attachment_id = $this->robot_id . str_pad($attachment_id, 3, '0', STR_PAD_LEFT); if (!isset($this->attachments[$attachment_id])) { $this_attachment = new rpg_attachment($this_player, $this_robot, $attachment_info); $this->attachments[$attachment_id] = $this_attachment; $this_attachment->update_session(); } if (!empty($this->attachments[$attachment_id])) { return true; } else { return false; } }