Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.76 KB | None | 0 0
  1. // Playground - noun: a place where people can play
  2.  
  3. import UIKit
  4.  
  5. class player {
  6.    
  7.     let clase:String
  8.     let hp:Double
  9.     let mp:Double
  10.     let str:Double
  11.     var currenthp:Double
  12.    
  13.     init(clase: String, hp: Double, mp: Double, str: Double, currenthp: Double){
  14.         self.clase = clase
  15.         self.hp = hp
  16.         self.mp = mp
  17.         self.str =  str
  18.         self.currenthp = currenthp
  19.     }
  20.    
  21.     func attack(target: player) {
  22.         target.currenthp = target.currenthp - self.str
  23.         if target.currenthp<=0{
  24.             println("\(target.clase) Murio! \(self.clase) gano 1 pvp")
  25.            
  26.         }else{
  27.            
  28.             println("\(self.clase) hizo \(self.str) de daño a \(target.clase) que quedo con \(target.currenthp)")
  29.         }
  30.        
  31.     }
  32.    
  33.     func heal(target: player) {
  34.         if target.currenthp + self.str > target.hp {
  35.             println("\(self.clase) hizo \(self.str - (target.hp - target.currenthp)) de heal a \(target.clase) que quedo con \(target.hp)")
  36.             target.currenthp = target.hp
  37.         }    else{
  38.             target.currenthp = target.currenthp + self.str
  39.                     println("\(self.clase) hizo \(self.str) de heal a \(target.clase) que quedo con \(target.currenthp)")
  40.         }
  41.  
  42.        
  43.     }
  44. }
  45.  
  46. var humano = player(clase: "Dagero", hp: 1500, mp: 500, str: 500, currenthp: 1500)
  47. var orco = player(clase: "Destroyer", hp: 2500, mp: 300, str: 20, currenthp: 2500)
  48. var elfa = player(clase: "Healer", hp: 1000, mp: 800, str: 100, currenthp: 1000)
  49.  
  50. humano.attack(orco)
  51. orco.attack(humano)
  52. elfa.heal(orco)
  53. humano.attack(orco)
  54. humano.attack(orco)
  55. humano.attack(orco)
  56. elfa.heal(orco)
  57. humano.attack(elfa)
  58. elfa.heal(elfa)
  59. humano.attack(orco)
  60. humano.attack(orco)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement