First of all here's my previous question so you see what I'm trying to make.
We are trying to make a Small game. We made a sort of monster fighting game. We made items to the game but I want them to drop by the monster. made different types and would like to know how to code to get a Drop Chance on the Items... like
So now I know how that works I'm stuck to get a random item from my list.
So what I actually want is to get a Random item of my "NormalType" list when i print it..
protocol NormalType {
var name: String { get }
}
class knife: NormalType {
let name = "Knife"
let Str = 10
}
class sword: NormalType {
let name = "Sword"
let Str = 20
}
class katana: NormalType {
let name = "Katana"
let Str = 30
}
class RareType {
class Knife: RareType {
var Str = 10
var Hp = 10
}
class sword: RareType {
var Str = 20
var HP = 15
}
class Katana: RareType {
var Str = 30
var Hp = 20
}
}
class LegendaryType {
class Knife: LegendaryType {
var Str = 10
}
class sword: LegendaryType {
var Str = 20
}
class Katana: LegendaryType {
var Str = 30
}
}
var Knife = knife()
var Sword = sword()
var Katana = katana()
var Items: [NormalType] = [Knife, Sword, Katana]
var randomnumber = (arc4random_uniform(2))
print(Items[randomnumber])