forked from kylebshr/chain-heal-swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.swift
66 lines (51 loc) · 1.68 KB
/
Player.swift
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
//
// Player.swift
// chain-heal
//
// Created by Kyle Bashour on 12/7/15.
// Copyright © 2015 Kyle Bashour. All rights reserved.
//
import Foundation
/// A class for holding a player with all its info
class Player: CustomStringConvertible {
let position: Point
let name: String
let maxPP: Int
let currentPP: Int
var healing = 0
var bestHealing = 0
var adjacentPlayers = [Player]()
var visited = false
var previousPlayer: Player?
/// For debugging: allows you to see the name and all adjacent players
var description: String {
var string = "\(name)\n"
for player in self.adjacentPlayers {
string += " \(player.name)\n"
}
return string
}
/**
Create a player with PP, a position (as a Point) and a name.
- parameter maxPP: The maximum PP this player can be healed to
- parameter currentPP: The current PP of the player
- parameter position: The position (Point holds an x and y value)
- parameter name: The Player name
- returns: A Player object instantiated with the given arguments
*/
init(maxPP: Int, currentPP: Int, position: Point, name: String) {
self.maxPP = maxPP
self.currentPP = currentPP
self.position = position
self.name = name
}
/**
Heals the player and returns how much the player was healed.
- parameter potential: The potential healing power
- returns: How much the player was able to heal themselves
*/
func heal(potential: Int) -> Int {
healing = min(potential, maxPP - currentPP)
return healing
}
}