Compare commits
12 Commits
Author | SHA1 | Date |
---|---|---|
|
c2dd429e9c | 2 years ago |
|
df73330ce4 | 2 years ago |
|
945f0eeda5 | 2 years ago |
|
1e46767d2b | 2 years ago |
|
b47c4f4c88 | 2 years ago |
![]() |
af20aa2832 | 2 years ago |
![]() |
1dab25c89e | 2 years ago |
![]() |
20df5325ab | 2 years ago |
![]() |
245ff1bffd | 2 years ago |
![]() |
043dd9ca4f | 2 years ago |
|
37b8b0f95d | 2 years ago |
|
ee76fcb954 | 2 years ago |
After Width: | Height: | Size: 88 KiB |
After Width: | Height: | Size: 44 KiB |
@ -1,3 +0,0 @@
|
||||
package com.example.shakecraft.view.viewholder
|
||||
class ViewHolderInventory(inflate: Any?) {
|
||||
}
|
@ -1,13 +1,39 @@
|
||||
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.Player
|
||||
import com.example.shakecraft.model.Item
|
||||
import com.example.shakecraft.model.Recipe
|
||||
|
||||
class MainViewModel : ViewModel() {
|
||||
|
||||
var currentPlayer : Player = Stub().load()
|
||||
var currentPlayer = MutableLiveData(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