Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Playground - noun: a place where people can play
- import UIKit
- class player {
- let clase:String
- let hp:Double
- let mp:Double
- let str:Double
- var currenthp:Double
- init(clase: String, hp: Double, mp: Double, str: Double, currenthp: Double){
- self.clase = clase
- self.hp = hp
- self.mp = mp
- self.str = str
- self.currenthp = currenthp
- }
- func attack(target: player) {
- target.currenthp = target.currenthp - self.str
- if target.currenthp<=0{
- println("\(target.clase) Murio! \(self.clase) gano 1 pvp")
- }else{
- println("\(self.clase) hizo \(self.str) de daño a \(target.clase) que quedo con \(target.currenthp)")
- }
- }
- func heal(target: player) {
- if target.currenthp + self.str > target.hp {
- println("\(self.clase) hizo \(self.str - (target.hp - target.currenthp)) de heal a \(target.clase) que quedo con \(target.hp)")
- target.currenthp = target.hp
- } else{
- target.currenthp = target.currenthp + self.str
- println("\(self.clase) hizo \(self.str) de heal a \(target.clase) que quedo con \(target.currenthp)")
- }
- }
- }
- var humano = player(clase: "Dagero", hp: 1500, mp: 500, str: 500, currenthp: 1500)
- var orco = player(clase: "Destroyer", hp: 2500, mp: 300, str: 20, currenthp: 2500)
- var elfa = player(clase: "Healer", hp: 1000, mp: 800, str: 100, currenthp: 1000)
- humano.attack(orco)
- orco.attack(humano)
- elfa.heal(orco)
- humano.attack(orco)
- humano.attack(orco)
- humano.attack(orco)
- elfa.heal(orco)
- humano.attack(elfa)
- elfa.heal(elfa)
- humano.attack(orco)
- humano.attack(orco)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement