Compare commits

..

12 Commits

Author SHA1 Message Date
Lucas DELANIER c2dd429e9c Mise à jour de 'README.md'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas DELANIER df73330ce4 Mise à jour de 'README.md'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas DELANIER 945f0eeda5 Mise à jour de 'README.md'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas DELANIER 1e46767d2b Mise à jour de 'README.md'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas DELANIER b47c4f4c88 Mise à jour de 'README.md'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier af20aa2832 correct bugs
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier 1dab25c89e livedata and observer on needed fragments
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier 20df5325ab livedata and observer on needed fragments
2 years ago
Lucas Delanier 245ff1bffd working livedata on craft
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier 043dd9ca4f fix problem string
2 years ago
Lucas DELANIER 37b8b0f95d Transférer les fichiers vers 'Documentations'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas DELANIER ee76fcb954 Transférer les fichiers vers 'Documentations'
continuous-integration/drone/push Build is passing Details
2 years ago

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

@ -34,12 +34,29 @@ La page "Dungeon" est une page de jeu dans laquelle le joueur doit secouer son t
![](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png)
## :bar_chart: distribution of work
- ✅ Fragment Home : Lucas Delanier <img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ Fragment Craft : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ Fragment Forge : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ Fragment Boss : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ Fragment Collect : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ Gestion de la rotation de l'écran Home fragment : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ Gestion du capteur Accélérometre : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ RecyclerView, Adapter, viewholder : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ ViewModel : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ LiveData : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ Model, Player, Item, Tool, Boss, ItemManager, Generator : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- ✅ Requete API, retrofit : Lucas Delanier<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"></br>
- 👷 Persistence profonde : Lucas Delanier, Theo Renaud<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="20px"><img src ="https://codefirst.iut.uca.fr/git/avatars/af9299d66a9a0bf7be17f8dc156f67b9?size=870" height="20px"></br>
## :dizzy: Getting Started
Une fois le dépot cloné, vous pouvez lancer le code sur votre téléphone Android grace a l'outil Android studio ou grace a un émulateur android.
## :gift: OverView
<p align="center">

@ -63,7 +63,8 @@ class BossFragment() : Fragment() {
setUpRecyclerView(view)
// Set up accelerometer listener
setUpAccelerometerListener(view, viewModel.currentPlayer)
viewModel.currentPlayer.value?.let { setUpAccelerometerListener(view, it) }
// Set up activity orientation
setUpActivityOrientation()

@ -53,7 +53,7 @@ class CollectFragment() : Fragment() {
initializeViews(view)
// Set up accelerometer listener
setUpAccelerometerListener(view,viewModel.currentPlayer)
viewModel.currentPlayer.value?.let { setUpAccelerometerListener(view, it) }
// Set up activity orientation
setUpActivityOrientation()
@ -103,7 +103,7 @@ class CollectFragment() : Fragment() {
// Generate a resource item and XP reward
val item = Generator.generateLootCollection()
currentPlayer.addItem(item)
viewModel.addItem(item)
currentPlayer.gainXp(item.type.xpReward)
//reset to 0 the progress bar

@ -9,6 +9,7 @@ import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.Observer
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
@ -29,7 +30,7 @@ class CraftFragment : Fragment() {
private lateinit var buttonForgeMax: Button
private lateinit var numberCraftable: TextView
private lateinit var craftValue : TextView
val viewModel : MainViewModel by activityViewModels<MainViewModel>()
private val viewModel : MainViewModel by activityViewModels()
override fun onCreate(savedInstanceState: Bundle?) {
@ -45,8 +46,12 @@ class CraftFragment : Fragment() {
val view = inflater.inflate(R.layout.fragment_craft, container, false)
recipe = arguments?.getParcelable("recipe")!!
initializeViews(view, viewModel.currentPlayer)
setUpRecyclerView(view,viewModel.currentPlayer)
viewModel.currentPlayer.observe(this.viewLifecycleOwner, Observer {player ->
initializeViews(view, player)
setUpRecyclerView(view, player)
})
return view
}
@ -85,14 +90,10 @@ class CraftFragment : Fragment() {
craftValue.text = recipe.item.stack.toString()
buttonForge.setOnClickListener{
currentPlayer.craft(recipe)
initializeViews(view, currentPlayer)
setUpRecyclerView(view, currentPlayer)
viewModel.craft(recipe)
}
buttonForgeMax.setOnClickListener{
currentPlayer.craft(recipe, RecipeManager.HowManyCraftable(recipe, currentPlayer))
initializeViews(view, currentPlayer)
setUpRecyclerView(view, currentPlayer)
viewModel.craft(recipe, RecipeManager.HowManyCraftable(recipe, currentPlayer))
}

@ -12,6 +12,7 @@ import android.widget.ProgressBar
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.Observer
import androidx.navigation.NavOptions
import androidx.navigation.fragment.findNavController
import com.example.shakecraft.model.Player
@ -46,7 +47,11 @@ class HomeFragment : Fragment() {
val view = inflater.inflate(R.layout.fragment_home,container,false)
// Initialize views
initializeViews(view, viewModel.currentPlayer, isRaining)
viewModel.currentPlayer.observe(viewLifecycleOwner, Observer {
initializeViews(view, it, isRaining)
})
return view
}

@ -23,11 +23,11 @@ class InventoryFragment() : Fragment( ), AdapterInventory.OnItemLongClickListene
}
override fun onItemLongClick(position: Int) {
if (viewModel.currentPlayer.items[position] is Tool) {
val text = if (viewModel.currentPlayer.equipeItem(viewModel.currentPlayer.items[position]) ) " was well equipped" else " has been well unequipped"
if (viewModel.currentPlayer.value!!.items[position] is Tool) {
val text = if (viewModel.equipeItem(viewModel.currentPlayer.value!!.items[position]) ) " was well equipped" else " has been well unequipped"
Toast.makeText(
context,
viewModel.currentPlayer.items[position].type.name + text,
viewModel.currentPlayer.value!!.items[position].type.name + text,
Toast.LENGTH_SHORT
).show()
setUpRecyclerView(view?.parent as ViewGroup, this)
@ -49,7 +49,11 @@ class InventoryFragment() : Fragment( ), AdapterInventory.OnItemLongClickListene
recyclerView = view.findViewById(R.id.recyclerviewInventory)
with(recyclerView) {
layoutManager = LinearLayoutManager(view.context)
adapter = AdapterInventory(viewModel.currentPlayer.items, listener , viewModel.currentPlayer)
adapter = viewModel.currentPlayer.value?.let {
AdapterInventory(viewModel.currentPlayer.value!!.items, listener ,
it
)
}
}
}

@ -4,21 +4,18 @@ import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import androidx.activity.viewModels
import androidx.annotation.RequiresApi
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.findNavController
import androidx.navigation.ui.NavigationUI
import androidx.navigation.ui.setupWithNavController
import com.example.shakecraft.services.OpenWeatherMapService
import com.example.shakecraft.viewmodel.MainViewModel
import com.google.android.material.bottomnavigation.BottomNavigationView
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlinx.coroutines.*
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
@ -26,8 +23,7 @@ import retrofit2.converter.gson.GsonConverterFactory
class MainActivity: AppCompatActivity() {
var isRaining = false
private lateinit var viewModel: MainViewModel
private val model: MainViewModel by viewModels()
@RequiresApi(Build.VERSION_CODES.R)
private fun hideSystemUI() {
@ -48,8 +44,6 @@ class MainActivity: AppCompatActivity() {
super.onCreate(savedInstanceState)
hideSystemUI()
setContentView(R.layout.activity_main)
viewModel = ViewModelProvider(this).get(MainViewModel::class.java)
val apiKey = "85a2724ad38b3994c2b7ebe1d239bbff"
val cityName = "Clermont-Ferrand"
@ -60,10 +54,8 @@ class MainActivity: AppCompatActivity() {
val openWeatherMapService = retrofit.create(OpenWeatherMapService::class.java)
GlobalScope.launch(Dispatchers.Main) {
val weatherResponse = withContext(Dispatchers.IO) {
openWeatherMapService.getCurrentWeather(cityName, apiKey)
}
CoroutineScope(Dispatchers.IO).launch {
val weatherResponse = openWeatherMapService.getCurrentWeather(cityName, apiKey)
isRaining =
weatherResponse.weather.any { it.main.contains("rain", ignoreCase = true) }

@ -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
}
}

@ -6,4 +6,7 @@
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="landscape">landscape</string>
<string name="wikiImage">Wiki image</string>
<string name="ancient_forge">Ancient Forge</string>
<string name="recipe">Recipe</string>
<string name="image_of_item">Image</string>
</resources>
Loading…
Cancel
Save