Compare commits
No commits in common. 'master' and 'viewmodel' have entirely different histories.
Before Width: | Height: | Size: 88 KiB |
Before Width: | Height: | Size: 44 KiB |
@ -0,0 +1,3 @@
|
||||
package com.example.shakecraft.view.viewholder
|
||||
class ViewHolderInventory(inflate: Any?) {
|
||||
}
|
@ -1,39 +1,13 @@
|
||||
package com.example.shakecraft.viewmodel
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.example.shakecraft.data.Stub
|
||||
import com.example.shakecraft.model.Boss
|
||||
import com.example.shakecraft.model.Item
|
||||
import com.example.shakecraft.model.Recipe
|
||||
import com.example.shakecraft.model.Player
|
||||
|
||||
class MainViewModel : ViewModel() {
|
||||
|
||||
var currentPlayer = MutableLiveData(Stub().load())
|
||||
|
||||
|
||||
var currentPlayer : Player = Stub().load()
|
||||
lateinit var currentBoss : Boss
|
||||
val isBossInitialized get() = this::currentBoss.isInitialized
|
||||
|
||||
fun craft(recipe : Recipe, count : Int = 1){
|
||||
currentPlayer.value?.craft(recipe, count)
|
||||
this.currentPlayer.value = currentPlayer.value
|
||||
}
|
||||
|
||||
fun addItem(item: Item) {
|
||||
currentPlayer.value?.addItem(item)
|
||||
this.currentPlayer.value = currentPlayer.value
|
||||
|
||||
}
|
||||
|
||||
fun gainXp(xpReward: Int) {
|
||||
currentPlayer.value?.gainXp(xpReward)
|
||||
this.currentPlayer.value = currentPlayer.value
|
||||
}
|
||||
|
||||
fun equipeItem(item: Item): Boolean {
|
||||
currentPlayer.value?.equipeItem(item)
|
||||
this.currentPlayer.value = currentPlayer.value
|
||||
return true
|
||||
}
|
||||
}
|
Loading…
Reference in new issue