Compare commits

..

9 Commits

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

@ -18,42 +18,25 @@
[![Technical Debt](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=ShakeAndCraft&metric=sqale_index&token=bb717076471bf71ba25b805c0b6ad18e4ae5c047)](https://codefirst.iut.uca.fr/sonar/dashboard?id=ShakeAndCraft)
[![Duplicated Lines (%)](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=ShakeAndCraft&metric=duplicated_lines_density&token=bb717076471bf71ba25b805c0b6ad18e4ae5c047)](https://codefirst.iut.uca.fr/sonar/dashboard?id=ShakeAndCraft)
**ShakeAndCraft** est un jeu mobile de type RPG dans lequel vous etes invités a secouer votre téléphone pour récuperer des ressources ainsi que combattre des boss surpuissants. Vous y découvrirais également un systeme de craft et d'évenement relié a la météo en temps réel.
**ShakeAndCraft** est un jeu mobile de type RPG dans lequel vous êtes invités a secouer votre téléphone pour récupérer des ressources ainsi que combattre des boss surpuissants. Vous y découvrirEZ également un système de crafts et d'événements reliés a la météo en temps réel.
## :floppy_disk: FEATURES
Sur la page principale, vous pouvez voir les informations de votre personnages ( pseudo, level, xp, rank) ainsi que des boutons de navigtions vers les pages de jeu.
Sur la page principale, vous pouvez voir les informations de votre personnages ( pseudo, level, xp, rank) ainsi que des boutons de navigation vers les pages de jeu.
La page "Inventory" vous permet de voir tous les items que vous possédez dans une liste dans laquelle vous pouvez rechercher par le nom un item en particulié.
La page "Ancient Forge" affiche les crafts disponibles dans le jeu avec un effet grisé pour les crafts qui ne peuvent pas etre fabriqués.
La page "Pleasent Forest" est une page de jeu dans laquelle le joueur doit secouer son téléphone pour charger une barre dechargement. Une fois celle ci compete, un item est choisi selon sa rareté affiché sur l'écran et est ajouté a l'inventaire du joueur.
La page "Pleasent Forest" est une page de jeu dans laquelle le joueur doit secouer son téléphone pour charger une barre de chargement. Une fois celle ci complète, un item est choisi selon sa rareté affiché sur l'écran et est ajouté a l'inventaire du joueur.
La page "Dungeon" est une page de jeu dans laquelle le joueur doit secouer son téléphone pour faire déscendre la vie d'un Boss beaucoup plus compliqué que la recolte de ressources. Une fois le boss tué, un item est ajouté a l'inventaire du joueur selon la rareté affiché a l'écran.
La page "Dungeon" est une page de jeu dans laquelle le joueur doit secouer son téléphone pour faire descendre la vie d'un Boss beaucoup plus compliqué que la recolte de ressources. Une fois le boss tué, un item est ajouté a l'inventaire du joueur selon la rareté affiché a l'écran.
![](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.
Une fois le dépot cloné, vous pouvez lancer le code sur votre téléphone Android ou sur un émulateur Android grace a l'outil Android studio.
@ -65,7 +48,7 @@ Une fois le dépot cloné, vous pouvez lancer le code sur votre téléphone Andr
## :wrench: SUPPORT
En cas de problème lors de l'utilisation de l'application, vous pouvez nous contacer aux adresses suivantes :
En cas de problème lors de l'utilisation de l'application, vous pouvez nous contacter aux adresses suivantes :
Lucas Delanier : **lucas.delanier@etu.uca.fr** </br>

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="NONE" />
</component>
<component name="ChangeListManager">
<list default="true" id="c1d3a00b-b752-49c3-9cf2-bbd65379556a" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../.." />
</component>
<component name="ProjectId" id="2N679bs9cUF2LZx6uhUfUbDiBup" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.cidr.known.project.marker": "true",
"cidr.known.project.marker": "true",
"last_opened_file_path": "D:/ShakeAndCraft/ShakeAndCraft/ShakeAndCraft"
}
}]]></component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="c1d3a00b-b752-49c3-9cf2-bbd65379556a" name="Changes" comment="" />
<created>1678972527401</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1678972527401</updated>
</task>
<servers />
</component>
</project>

@ -33,37 +33,24 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
packagingOptions {
exclude 'META-INF/atomicfu.kotlin_module'
}
}
apply plugin: 'kotlin-kapt'
dependencies {
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
dependencies {
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'com.google.ar.sceneform:filament-android:1.17.1'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
implementation 'androidx.fragment:fragment-ktx:1.5.6'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
implementation "androidx.room:room-runtime:2.5.1"
kapt "androidx.room:room-compiler:2.5.1"
implementation "androidx.room:room-ktx:2.5.1"
//Retrofit
implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
//Coroutine
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
kapt 'androidx.room:room-compiler:2.5.1'
implementation 'androidx.room:room-ktx:2.5.1'
implementation 'androidx.room:room-runtime:2.5.1'
}

@ -1,62 +0,0 @@
package com.example.shakecraft
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.shakecraft.model.Tool
import com.example.shakecraft.view.adapter.AdapterInventory
import com.example.shakecraft.viewmodel.MainViewModel
class InventoryFragment() : Fragment( ), AdapterInventory.OnItemLongClickListener {
private lateinit var recyclerView: RecyclerView
val viewModel : MainViewModel by activityViewModels<MainViewModel>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onItemLongClick(position: Int) {
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.value!!.items[position].type.name + text,
Toast.LENGTH_SHORT
).show()
setUpRecyclerView(view?.parent as ViewGroup, this)
}
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_inventory, container, false)
// Initialize views
setUpRecyclerView(view, this)
return view
}
private fun setUpRecyclerView(view: View,listener: AdapterInventory.OnItemLongClickListener ) {
recyclerView = view.findViewById(R.id.recyclerviewInventory)
with(recyclerView) {
layoutManager = LinearLayoutManager(view.context)
adapter = viewModel.currentPlayer.value?.let {
AdapterInventory(viewModel.currentPlayer.value!!.items, listener ,
it
)
}
}
}
}

@ -4,26 +4,21 @@ 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.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.example.shakecraft.data.Stub
import com.google.android.material.bottomnavigation.BottomNavigationView
import kotlinx.coroutines.*
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
class MainActivity : AppCompatActivity() {
class MainActivity: AppCompatActivity() {
var currentPlayer = Stub().load()
var isRaining = false
private val model: MainViewModel by viewModels()
@RequiresApi(Build.VERSION_CODES.R)
private fun hideSystemUI() {
@ -44,46 +39,14 @@ class MainActivity: AppCompatActivity() {
super.onCreate(savedInstanceState)
hideSystemUI()
setContentView(R.layout.activity_main)
val apiKey = "85a2724ad38b3994c2b7ebe1d239bbff"
val cityName = "Clermont-Ferrand"
val retrofit = Retrofit.Builder()
.baseUrl("https://api.openweathermap.org/data/2.5/")
.addConverterFactory(GsonConverterFactory.create())
.build()
val openWeatherMapService = retrofit.create(OpenWeatherMapService::class.java)
CoroutineScope(Dispatchers.IO).launch {
val weatherResponse = openWeatherMapService.getCurrentWeather(cityName, apiKey)
isRaining =
weatherResponse.weather.any { it.main.contains("rain", ignoreCase = true) }
println(isRaining)
}
bottomNav = findViewById(R.id.bottomNavigationView)
val navController = findNavController(R.id.fragment)
navController.popBackStack(R.id.fragment, false)
bottomNav.setupWithNavController(navController)
bottomNav.setOnItemReselectedListener { item ->
// Pop everything up to the reselected item
val reselectedDestinationId = item.itemId
navController.popBackStack(reselectedDestinationId, inclusive = false)
}
bottomNav.setOnItemSelectedListener { item ->
NavigationUI.onNavDestinationSelected(item, navController)
true
}
}
override fun onResume() {
super.onResume()
@ -96,5 +59,4 @@ class MainActivity: AppCompatActivity() {
}

@ -0,0 +1,8 @@
package com.example.shakecraft
import android.app.Application
import com.example.shakecraft.data.DataBase
class PlayerApplication: Application(){
val database: DataBase by lazy { DataBase.getInstance(this) }
}

@ -0,0 +1,60 @@
package com.example.shakecraft
import androidx.lifecycle.LiveData
import androidx.lifecycle.asLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import com.example.shakecraft.data.PlayerDao
import com.example.shakecraft.model.Player
import kotlinx.coroutines.launch
class PlayerViewModel(private val playerDao: PlayerDao): ViewModel() {
val player:LiveData<Player> = playerDao.getPlayer()
.asLiveData()
fun updatePlayer(
Id: Int,
pseudo: String,
level: Int,
xp: Int,
image: Int,
rank: String,
){
val updatePlayer= getUpdatePlayerEntry(Id, pseudo, level, xp, image, rank)
updatePlayer(updatePlayer)
}
private fun updatePlayer(player: Player) {
viewModelScope.launch{
playerDao.update(player)
}
}
private fun getUpdatePlayerEntry(
Id: Int,
pseudo: String,
level: Int,
xp: Int,
image: Int,
rank: String,
): Player {
return Player(
id= Id,
pseudo= pseudo,
level= level,
xp= xp,
image= image,
rank= rank,
)
}
}
class PlayerViewModelFactory(private val playerDao: PlayerDao): ViewModelProvider.Factory{
fun <T : ViewModel?> create(modelClass: Class<T>): T {
if (modelClass.isAssignableFrom(PlayerViewModel::class.java)){
@Suppress("UNCHECKED_CAST")
return PlayerViewModel(playerDao) as T
}
throw IllegalArgumentException("Unknown ViewModel class")
}
}

@ -0,0 +1,28 @@
package com.example.shakecraft.data
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.example.shakecraft.model.Player
import android.content.Context
@Database(entities = [Player::class],version = 1)
abstract class DataBase: RoomDatabase() {
abstract fun playerDao(): PlayerDao
companion object{
private var INSTANCE : DataBase? = null
fun getInstance(context: Context): DataBase{
return INSTANCE ?: synchronized(this){
val instance = Room.databaseBuilder(
context.applicationContext,
DataBase::class.java,
"player_database"
)
.fallbackToDestructiveMigration()
.build()
INSTANCE = instance
instance
}
}
}
}

@ -0,0 +1,21 @@
package com.example.shakecraft.data
import androidx.room.*
import com.example.shakecraft.model.Player
import kotlinx.coroutines.flow.Flow
@Dao
interface PlayerDao {
@Query("SELECT * FROM Player")
fun getPlayer(): Flow<Player>
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert(player: Player)
@Update
suspend fun update(player: Player)
@Delete
suspend fun delete(player: Player)
}

@ -1,16 +1,21 @@
package com.example.shakecraft.data
import com.example.shakecraft.model.*
import com.example.shakecraft.model.ItemManager.Companion.ITEMS
import com.example.shakecraft.model.Item
import com.example.shakecraft.model.Player
class Stub {
fun load() : Player{
val currentPlayer = Player("Winker",0)
currentPlayer.addItem(Item(type = ITEMS.BEECH_LOG.itemtype, stack = 30))
currentPlayer.addItem(Item(type = ITEMS.BRONZE_INGOT.itemtype, stack = 30))
currentPlayer.addItem(Tool(type = ITEMS.DIAMOND_AXE.itemtype, stack = 1, damage = 8))
val currentPlayer = Player()
val items : MutableList<Item> = mutableListOf()
items.add(Item(type = ITEMS.BEECH_LOG.itemtype, stack = 30))
items.add(Item(type = ITEMS.BRONZE_INGOT.itemtype, stack = 30))
items.add(Item(type = ITEMS.TREASURE.itemtype, stack = 2))
items.add(Item(type = ITEMS.TREASURE_KEY.itemtype, stack = 1))
currentPlayer.items = items
return currentPlayer
}

@ -1,19 +0,0 @@
package com.example.shakecraft.data
data class WeatherResponse(
val weather: List<Weather>,
val info: Info
)
data class Weather(
val id: Int,
val main: String,
val description: String,
val icon: String
)
data class Info(
val temp: Double,
val feelsLike: Double,
val humidity: Int
)

@ -1,15 +0,0 @@
package com.example.shakecraft.data.dao
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.example.shakecraft.model.Item
@Dao
interface ItemDao {
@Query("SELECT * FROM item")
suspend fun getAllItems(): List<Item>
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertItem(item: Item)
}

@ -1,16 +0,0 @@
package com.example.shakecraft.data.dao
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.example.shakecraft.model.Player
@Dao
interface PlayerDao {
@Query("SELECT * FROM player")
suspend fun getAllPlayers(): List<Player>
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertPlayer(player: Player)
}

@ -1,4 +1,4 @@
package com.example.shakecraft
package com.example.shakecraft.fragment
import android.content.Context
import android.content.pm.ActivityInfo
import android.hardware.Sensor
@ -16,16 +16,16 @@ import android.view.animation.ScaleAnimation
import android.widget.ImageView
import android.widget.ProgressBar
import android.widget.TextView
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.shakecraft.MainActivity
import com.example.shakecraft.R
import com.example.shakecraft.model.Boss
import com.example.shakecraft.model.Generator
import com.example.shakecraft.model.Item
import com.example.shakecraft.model.Player
import com.example.shakecraft.view.adapter.AdapterBossLoot
import com.example.shakecraft.viewmodel.MainViewModel
import kotlin.math.pow
import kotlin.math.sqrt
@ -39,7 +39,7 @@ class BossFragment() : Fragment() {
private lateinit var image: ImageView
private lateinit var buttonCollect: TextView
private lateinit var recyclerView: RecyclerView
val viewModel : MainViewModel by activityViewModels<MainViewModel>()
private lateinit var boss: Boss
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -49,22 +49,21 @@ class BossFragment() : Fragment() {
savedInstanceState: Bundle?
): View? {
val currentPlayer = (activity as MainActivity).currentPlayer
val view = inflater.inflate(R.layout.fragment_boss, container, false)
// Initialize views
initializeViews(view)
// Set up boss
if(!viewModel.isBossInitialized)
viewModel.currentBoss = Generator.generateBoss()
setUpBoss(viewModel.currentBoss)
boss = Generator.generateBoss()
setUpBoss(boss)
// Set up RecyclerView for boss loot
setUpRecyclerView(view)
// Set up accelerometer listener
viewModel.currentPlayer.value?.let { setUpAccelerometerListener(view, it) }
setUpAccelerometerListener(view, currentPlayer)
// Set up activity orientation
setUpActivityOrientation()
@ -82,7 +81,7 @@ class BossFragment() : Fragment() {
}
private fun setUpBoss(boss: Boss) {
progressBar.max = boss.maxlife
progressBar.progress = boss.life.toInt()
progressBar.progress = boss.life
image.setImageResource(boss.image)
// Create scale animation for boss image
@ -105,7 +104,7 @@ class BossFragment() : Fragment() {
recyclerView = view.findViewById(R.id.recyclerviewBossLoot)
with(recyclerView) {
layoutManager = LinearLayoutManager(view.context)
adapter = AdapterBossLoot(viewModel.currentBoss.possibleLoot)
adapter = AdapterBossLoot(boss.possibleLoot)
}
}
private fun setUpActivityOrientation(){
@ -120,7 +119,7 @@ class BossFragment() : Fragment() {
toastView.visibility = View.VISIBLE
lootImage.setImageResource(item.type.image)
lootName.text = item.type.name
xpReward.text = viewModel.currentBoss.xpReward.toString()
xpReward.text = boss.xpReward.toString()
toastView.postDelayed({
toastView.visibility = View.GONE
}, 3000)
@ -134,36 +133,31 @@ class BossFragment() : Fragment() {
}
override fun onSensorChanged(event: SensorEvent?) {
val acceleration = sqrt(event!!.values[0].pow(2) + event.values[1].pow(2) + event.values[2].pow(2))
if (viewModel.currentBoss.life <= 0) {
if (boss.life <= 0) {
//Vibration to signal the death of the boss
val vibrator = context?.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
vibrator.vibrate(100)
// Generate a loot item and XP reward
val item = Generator.generateLootBoss(viewModel.currentBoss.possibleLoot)
currentPlayer.addItem(item)
currentPlayer.gainXp(viewModel.currentBoss.xpReward)
val item = Generator.generateLootBoss(boss.possibleLoot)
currentPlayer.inventory.addItem(item)
currentPlayer.gainXp(boss.xpReward)
// Show loot toast view for 3 seconds
displayToast(view,item)
// Spawn new boss and reset progress bar
viewModel.currentBoss = Generator.generateBoss()
setUpBoss(viewModel.currentBoss)
boss = Generator.generateBoss()
setUpBoss(boss)
//Update displayed information
setUpRecyclerView(view)
} else {
if(acceleration > 20){
viewModel.currentBoss.takeDamage(((acceleration / 80)+ currentPlayer.attack()/100).toDouble())
}
else{
viewModel.currentBoss.takeDamage(currentPlayer.attack().toDouble()/100)
}
progressBar.progress = viewModel.currentBoss.life.toInt()
// Reduce boss life based on acceleration value
boss.takeDamage((acceleration / 80).toInt())
progressBar.progress = boss.life
}
}
}

@ -1,4 +1,4 @@
package com.example.shakecraft
package com.example.shakecraft.fragment
import android.content.Context
@ -16,14 +16,14 @@ import android.view.ViewGroup
import android.widget.ImageView
import android.widget.ProgressBar
import android.widget.TextView
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
import com.example.shakecraft.MainActivity
import com.example.shakecraft.R
import com.example.shakecraft.model.Generator
import com.example.shakecraft.model.Item
import com.example.shakecraft.model.Player
import com.example.shakecraft.viewmodel.MainViewModel
import kotlin.math.pow
@ -36,7 +36,6 @@ class CollectFragment() : Fragment() {
private lateinit var accelerometerEventListener: SensorEventListener
private lateinit var progressBar: ProgressBar
private lateinit var buttonBack: TextView
val viewModel : MainViewModel by activityViewModels<MainViewModel>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -47,13 +46,14 @@ class CollectFragment() : Fragment() {
savedInstanceState: Bundle?
): View? {
val currentPlayer = (activity as MainActivity).currentPlayer
val view = inflater.inflate(R.layout.fragment_collect, container, false)
// Initialize views
initializeViews(view)
// Set up accelerometer listener
viewModel.currentPlayer.value?.let { setUpAccelerometerListener(view, it) }
setUpAccelerometerListener(view,currentPlayer)
// Set up activity orientation
setUpActivityOrientation()
@ -103,7 +103,7 @@ class CollectFragment() : Fragment() {
// Generate a resource item and XP reward
val item = Generator.generateLootCollection()
viewModel.addItem(item)
currentPlayer.inventory.addItem(item)
currentPlayer.gainXp(item.type.xpReward)
//reset to 0 the progress bar

@ -1,4 +1,4 @@
package com.example.shakecraft
package com.example.shakecraft.fragment
import android.os.Bundle
import androidx.fragment.app.Fragment
@ -8,16 +8,16 @@ import android.view.ViewGroup
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
import com.example.shakecraft.MainActivity
import com.example.shakecraft.R
import com.example.shakecraft.model.Player
import com.example.shakecraft.model.Recipe
import com.example.shakecraft.model.RecipeManager
import com.example.shakecraft.view.adapter.AdapterMaterials
import com.example.shakecraft.viewmodel.MainViewModel
class CraftFragment : Fragment() {
@ -27,10 +27,7 @@ class CraftFragment : Fragment() {
private lateinit var image: ImageView
private lateinit var name: TextView
private lateinit var buttonForge: Button
private lateinit var buttonForgeMax: Button
private lateinit var numberCraftable: TextView
private lateinit var craftValue : TextView
private val viewModel : MainViewModel by activityViewModels()
override fun onCreate(savedInstanceState: Bundle?) {
@ -43,15 +40,12 @@ class CraftFragment : Fragment() {
): View? {
val currentPlayer = (activity as MainActivity).currentPlayer
val view = inflater.inflate(R.layout.fragment_craft, container, false)
recipe = arguments?.getParcelable("recipe")!!
viewModel.currentPlayer.observe(this.viewLifecycleOwner, Observer {player ->
initializeViews(view, player)
setUpRecyclerView(view, player)
})
initializeViews(view, currentPlayer)
setUpRecyclerView(view,currentPlayer)
return view
}
@ -73,9 +67,7 @@ class CraftFragment : Fragment() {
private fun initializeViews(view: View, currentPlayer: Player) {
buttonBack = view.findViewById(R.id.backbutton)
buttonForge = view.findViewById(R.id.buttonForge)
buttonForgeMax = view.findViewById(R.id.buttonForgeMax)
numberCraftable = view.findViewById(R.id.craftableNumber)
craftValue = view.findViewById(R.id.craftValue)
buttonBack.setOnClickListener{
findNavController().navigate(R.id.action_craftFragment_to_forgeFragment)
@ -84,16 +76,13 @@ class CraftFragment : Fragment() {
name = view.findViewById(R.id.item_name)
image.setImageResource(recipe.item.type.image)
name.text = recipe.item.type.name
buttonForge.isEnabled = RecipeManager.isCraftable(recipe,currentPlayer)
buttonForgeMax.isEnabled = RecipeManager.isCraftable(recipe,currentPlayer)
numberCraftable.text = RecipeManager.HowManyCraftable(recipe,currentPlayer).toString()
craftValue.text = recipe.item.stack.toString()
buttonForge.isEnabled = RecipeManager.isCraftable(recipe,currentPlayer.inventory)
numberCraftable.text = RecipeManager.HowManyCraftable(recipe,currentPlayer.inventory).toString()
buttonForge.setOnClickListener{
viewModel.craft(recipe)
}
buttonForgeMax.setOnClickListener{
viewModel.craft(recipe, RecipeManager.HowManyCraftable(recipe, currentPlayer))
currentPlayer.inventory.craft(recipe)
initializeViews(view, currentPlayer)
setUpRecyclerView(view, currentPlayer)
}

@ -1,4 +1,4 @@
package com.example.shakecraft
package com.example.shakecraft.fragment
import android.os.Bundle
import androidx.fragment.app.Fragment
@ -10,12 +10,12 @@ import androidx.core.os.bundleOf
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.shakecraft.R
import com.example.shakecraft.model.Recipe
import com.example.shakecraft.model.RecipeManager
import com.example.shakecraft.view.adapter.AdapterRecipe
class ForgeFragment : Fragment(), AdapterRecipe.OnItemClickListener {
private lateinit var buttonBack: TextView
private lateinit var recyclerViewObjects: RecyclerView

@ -1,26 +1,23 @@
package com.example.shakecraft
package com.example.shakecraft.fragment
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import android.widget.ImageView
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.MainActivity
import com.example.shakecraft.R
import com.example.shakecraft.model.Player
import com.example.shakecraft.viewmodel.MainViewModel
class HomeFragment : Fragment() {
private lateinit var pseudoEditText : EditText
private lateinit var pseudo : TextView
private lateinit var progressbar : ProgressBar
private lateinit var level : TextView
private lateinit var rank : TextView
@ -30,38 +27,25 @@ class HomeFragment : Fragment() {
private lateinit var buttonBoss : ConstraintLayout
private lateinit var buttonForge : ConstraintLayout
private lateinit var playermage : ImageView
private lateinit var equipeditem: ImageView
private lateinit var eventFishing: ImageView
val viewModel : MainViewModel by activityViewModels<MainViewModel>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val isRaining = (activity as MainActivity).isRaining
val currentPlayer = (activity as MainActivity).currentPlayer
val view = inflater.inflate(R.layout.fragment_home,container,false)
// Initialize views
viewModel.currentPlayer.observe(viewLifecycleOwner, Observer {
initializeViews(view, it, isRaining)
})
initializeViews(view, currentPlayer)
return view
}
/*fun loadWeatherDate(){
CoroutineScope(Dispatchers.IO).launch {
val
}
}*/
private fun initializeViews(view: View, currentPlayer : Player, isRaining : Boolean) {
private fun initializeViews(view: View, currentPlayer : Player) {
pseudo = view.findViewById(R.id.pseudoTextView)
progressbar = view.findViewById(R.id.levelProgressBar)
level = view.findViewById(R.id.levelTextView)
rank = view.findViewById(R.id.rankTextView)
@ -69,19 +53,24 @@ class HomeFragment : Fragment() {
xp = view.findViewById(R.id.xpTextView)
playermage = view.findViewById(R.id.playerImage)
buttonCollect = view.findViewById(R.id.buttonCollect)
equipeditem = view.findViewById(R.id.equipedItemAttack)
eventFishing = view.findViewById(R.id.buttonFishing)
buttonCollect.setOnClickListener{
findNavController().navigate(R.id.action_homeFragment_to_collectFragment, null, NavOptions.Builder().setPopUpTo(R.id.homeFragment, false).build())
findNavController().navigate(
R.id.action_homeFragment_to_collectFragment, null, NavOptions.Builder().setPopUpTo(
R.id.homeFragment, false).build())
}
buttonBoss = view.findViewById(R.id.buttonBoss)
buttonBoss.setOnClickListener{
findNavController().navigate(R.id.action_homeFragment_to_bossFragment, null, NavOptions.Builder().setPopUpTo(R.id.homeFragment, false).build())
findNavController().navigate(
R.id.action_homeFragment_to_bossFragment, null, NavOptions.Builder().setPopUpTo(
R.id.homeFragment, false).build())
}
buttonForge = view.findViewById(R.id.buttonForge)
buttonForge.setOnClickListener{
findNavController().navigate(R.id.action_homeFragment_to_forgeFragment, null, NavOptions.Builder().setPopUpTo(R.id.homeFragment, false).build())
findNavController().navigate(
R.id.action_homeFragment_to_forgeFragment, null, NavOptions.Builder().setPopUpTo(
R.id.homeFragment, false).build())
}
pseudo.text = currentPlayer.pseudo
level.text = currentPlayer.level.toString()
rank.text = currentPlayer.rank
xp.text = currentPlayer.xp.toString()
@ -89,35 +78,6 @@ class HomeFragment : Fragment() {
progressbar.progress = currentPlayer.xp
progressbar.max = currentPlayer.level*100
playermage.setImageResource(currentPlayer.image)
if(currentPlayer.equipedItem?.type?.image != null) {
equipeditem.setImageResource(currentPlayer.equipedItem!!.type.image)
}
if(isRaining){
eventFishing.visibility = View.VISIBLE
}
pseudoEditText = view.findViewById(R.id.pseudoEditText)
pseudoEditText.setText(currentPlayer.pseudo)
pseudoEditText.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
/*
do nothing
*/
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
/*
do nothing
*/
}
override fun afterTextChanged(s: Editable?) {
currentPlayer.pseudo = s.toString()
}
})
}

@ -0,0 +1,44 @@
package com.example.shakecraft.fragment
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.shakecraft.MainActivity
import com.example.shakecraft.R
import com.example.shakecraft.model.Player
import com.example.shakecraft.view.adapter.AdapterInventory
class InventoryFragment() : Fragment( ) {
private lateinit var recyclerView: RecyclerView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val currentPlayer = (activity as MainActivity).currentPlayer
val view = inflater.inflate(R.layout.fragment_inventory, container, false)
// Initialize views
setUpRecyclerView(view, currentPlayer)
return view
}
private fun setUpRecyclerView(view: View, currentPlayer: Player) {
recyclerView = view.findViewById(R.id.recyclerviewInventory)
with(recyclerView) {
layoutManager = LinearLayoutManager(view.context)
adapter = AdapterInventory(currentPlayer.inventory.items)
}
}
}

@ -1,4 +1,4 @@
package com.example.shakecraft
package com.example.shakecraft.fragment
import android.content.Intent
import android.net.Uri
@ -8,6 +8,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import com.example.shakecraft.R
class PlusFragment : Fragment() {
private lateinit var buttonWiki : LinearLayout

@ -1,16 +1,19 @@
package com.example.shakecraft.model
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
class Boss (
data class Boss (
var name: String,
var life: Double,
var life: Int,
var maxlife: Int,
var image: Int,
var xpReward: Int,
val possibleLoot: List<Pair<Item, Double>>,
){
fun takeDamage(strength: Double) {
fun takeDamage(strength: Int) {
this.life -= strength
}
}

@ -1,5 +1,6 @@
package com.example.shakecraft.model
import com.example.shakecraft.R
import com.example.shakecraft.model.ItemManager.Companion.ITEMS
import kotlin.random.Random
class Generator {
@ -42,26 +43,26 @@ class Generator {
fun generateBoss(): Boss {
val possibleBoss: List<Pair<Boss, Double>> = listOf(
Pair(Boss(name = "Margit the Fell Omen", life = 150.0, maxlife = 150, image = R.drawable.boss, xpReward = 100, possibleLoot = listOf(
Pair(Boss(name = "Margit the Fell Omen", life = 150, maxlife = 150, image = R.drawable.boss, xpReward = 100, possibleLoot = listOf(
Pair(Item(type = ITEMS.MONSTER_BONES.itemtype), 0.7),
Pair(Item(type = ITEMS.MONSTER_EYE.itemtype), 0.3),
)), 0.5),
Pair(Boss(name = "Godrick the Grafted", life = 200.0, maxlife = 200, image = R.drawable.skeleton, xpReward = 130, possibleLoot = listOf(
Pair(Boss(name = "Godrick the Grafted", life = 200, maxlife = 200, image = R.drawable.skeleton, xpReward = 130, possibleLoot = listOf(
Pair(Item(type = ITEMS.MONSTER_BONES.itemtype), 0.6),
Pair(Item(type = ITEMS.MONSTER_EYE.itemtype), 0.3),
Pair(Item(type = ITEMS.TREASURE_KEY.itemtype), 0.1),
)), 0.2),
Pair(Boss(name = "Red Wolf of Radagon", life = 250.0, maxlife = 250, image = R.drawable.halberdier, xpReward = 210, possibleLoot = listOf(
Pair(Boss(name = "Red Wolf of Radagon", life = 250, maxlife = 250, image = R.drawable.halberdier, xpReward = 210, possibleLoot = listOf(
Pair(Item(type = ITEMS.MONSTER_BONES.itemtype), 0.6),
Pair(Item(type = ITEMS.MONSTER_EYE.itemtype), 0.3),
Pair(Item(type = ITEMS.TREASURE_KEY.itemtype), 0.1),
)), 0.15),
Pair(Boss(name = "Old Banshee", life = 300.0, maxlife = 300, image = R.drawable.banshee, xpReward = 300, possibleLoot = listOf(
Pair(Boss(name = "Old Banshee", life = 300, maxlife = 300, image = R.drawable.banshee, xpReward = 300, possibleLoot = listOf(
Pair(Item(type = ITEMS.MONSTER_BONES.itemtype), 0.4),
Pair(Item(type = ITEMS.MONSTER_EYE.itemtype), 0.4),
Pair(Item(type = ITEMS.TREASURE_KEY.itemtype), 0.2),
)), 0.10),
Pair(Boss(name = "Margit the Fell Omen", life = 500.0, maxlife = 500, image = R.drawable.lich, xpReward = 500, possibleLoot = listOf(
Pair(Boss(name = "Margit the Fell Omen", life = 500, maxlife = 500, image = R.drawable.lich, xpReward = 500, possibleLoot = listOf(
Pair(Item(type = ITEMS.MONSTER_BONES.itemtype), 0.4),
Pair(Item(type = ITEMS.MONSTER_EYE.itemtype), 0.3),
Pair(Item(type = ITEMS.TREASURE_KEY.itemtype), 0.3),
@ -79,5 +80,22 @@ class Generator {
// Si aucun élément n'a été choisi, retourner le dernier élément de la liste
return possibleBoss.last().first
}
fun generateTreasure(): Item{
val possibleTreasure: List<Pair<Item,Double>> = listOf(
Pair(Item(type = ITEMS.MONSTER_BONES.itemtype), 0.9),
)
val rand = Random.nextDouble()
var cumulativeProb = 0.0
for (element in possibleTreasure) {
cumulativeProb += element.second
if (rand < cumulativeProb) {
return element.first
}
}
// Si aucun élément n'a été choisi, retourner le dernier élément de la liste
return possibleTreasure.last().first
}
}
}

@ -3,14 +3,17 @@ package com.example.shakecraft.model
import android.os.Parcel
import android.os.Parcelable
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity(tableName = "items")
open class Item(
import androidx.room.ForeignKey
@Entity(tableName = "Item", foreignKeys = [ForeignKey(
entity = ItemType::class, parentColumns = arrayOf("name"),
childColumns = arrayOf("itemtype"),
onUpdate = ForeignKey.CASCADE,
onDelete = ForeignKey.CASCADE)])
class Item(
val type: ItemType,
var stack: Int = 1,
) : Parcelable {
@PrimaryKey(autoGenerate = true) val id: String = type.name
override fun describeContents(): Int {

@ -1,31 +1,35 @@
package com.example.shakecraft.model
import com.example.shakecraft.R
enum class ITEMS(val itemtype: ItemType){
// Craftable items and resources
BEECH_LOG(ItemType(name = "Beech Log", image = R.drawable.log2, rarity = 1, xpReward = 10)),
WOODEN_STICK(ItemType(name = "Wooden Stick", image = R.drawable.wooden_stick, rarity = 1, xpReward = 0)),
WOODEN_PLANK(ItemType(name = "Wooden Plank", image = R.drawable.wooden_plank, rarity = 1, xpReward = 0)),
WOODEN_BALL(ItemType(name = "Wooden Ball", image = R.drawable.wooden_ball, rarity = 1, xpReward = 0)),
WIZARD_STAFF(ItemType(name = "Wizard Staff", image = R.drawable.wizard_staff, rarity = 3, xpReward = 0)),
DIAMOND(ItemType(name = "Diamond", image = R.drawable.diamond, rarity = 3, xpReward = 30)),
DIAMOND_AXE(ItemType(name = "Diamond Axe", image = R.drawable.diamond_axe, rarity = 3, xpReward = 0)),
BRONZE_ORE(ItemType(name = "Bronze Ore", image = R.drawable.bronze_ore, rarity = 2, xpReward = 20)),
BRONZE_INGOT(ItemType(name = "Bronze Ingot", image = R.drawable.bronze_ingot, rarity = 1, xpReward = 0)),
BRONZE_SWORD(ItemType(name = "Bronze Sword", image = R.drawable.bronze_sword, rarity = 2, xpReward = 0)),
IRON_ORE(ItemType(name = "Iron Ore", image = R.drawable.iron_ore, rarity = 2, xpReward = 25)),
IRON_INGOT(ItemType(name = "Iron Ingot", image = R.drawable.iron_ingot, rarity = 1, xpReward = 0)),
// Lootable items
MONSTER_BONES(ItemType(name = "Monster Bones", image = R.drawable.monster_bones, rarity = 1, xpReward = 10)),
MONSTER_EYE(ItemType(name = "Monster Eye", image = R.drawable.monster_eyes, rarity = 2, xpReward = 20)),
TREASURE_KEY(ItemType(name = "Treasure Key", image = R.drawable.treasure_key, rarity = 2, xpReward = 20)),
}
class ItemManager {
companion object {
enum class ITEMS(val itemtype: ItemType){
// Craftable items and resources
BEECH_LOG(ItemType(name = "Beech Log", image = R.drawable.log2, rarity = 1, xpReward = 10)),
WOODEN_STICK(ItemType(name = "Wooden Stick", image = R.drawable.wooden_stick, rarity = 1, xpReward = 0)),
WOODEN_PLANK(ItemType(name = "Wooden Plank", image = R.drawable.wooden_plank, rarity = 1, xpReward = 0)),
WOODEN_BALL(ItemType(name = "Wooden Ball", image = R.drawable.wooden_ball, rarity = 1, xpReward = 0)),
WIZARD_STAFF(ItemType(name = "Wizard Staff", image = R.drawable.wizard_staff, rarity = 3, xpReward = 0)),
DIAMOND(ItemType(name = "Diamond", image = R.drawable.diamond, rarity = 3, xpReward = 30)),
DIAMOND_AXE(ItemType(name = "Diamond Axe", image = R.drawable.diamond_axe, rarity = 3, xpReward = 0)),
BRONZE_ORE(ItemType(name = "Bronze Ore", image = R.drawable.bronze_ore, rarity = 2, xpReward = 20)),
BRONZE_INGOT(ItemType(name = "Bronze Ingot", image = R.drawable.bronze_ingot, rarity = 1, xpReward = 0)),
BRONZE_SWORD(ItemType(name = "Bronze Sword", image = R.drawable.bronze_sword, rarity = 2, xpReward = 0)),
IRON_ORE(ItemType(name = "Iron Ore", image = R.drawable.iron_ore, rarity = 2, xpReward = 25)),
IRON_INGOT(ItemType(name = "Iron Ingot", image = R.drawable.iron_ingot, rarity = 1, xpReward = 0)),
OPEN_TREASURE(ItemType(name = "Open Treasure", image = R.drawable.open_treasure, rarity = 3, xpReward = 50)),
// Lootable items
MONSTER_BONES(ItemType(name = "Monster Bones", image = R.drawable.monster_bones, rarity = 1, xpReward = 10)),
MONSTER_EYE(ItemType(name = "Monster Eye", image = R.drawable.monster_eyes, rarity = 2, xpReward = 20)),
TREASURE_KEY(ItemType(name = "Treasure Key", image = R.drawable.treasure_key, rarity = 2, xpReward = 20)),
TREASURE(ItemType(name = "Treasure", image = R.drawable.treasure, rarity = 3, xpReward = 20)),
}
}
}

@ -1,6 +1,6 @@
package com.example.shakecraft.model
class ItemType (val name : String,val image : Int,val rarity : Int, val xpReward : Int){
class ItemType (val name : String,val image : Int,val rarity : Int, val xpReward : Int){
}

@ -1,18 +1,26 @@
package com.example.shakecraft.model
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.example.shakecraft.R
class Player(var pseudo: String, var xp: Int = 0) {
var level: Int = 1
private set
@Entity(tableName="Player")
class Player() {
@PrimaryKey(autoGenerate = true)
val id : Int = 0
@ColumnInfo(name = "name")
val pseudo: String = "Unknow"
@ColumnInfo(name = "level")
var level: Int = 0
@ColumnInfo(name = "xp")
var xp: Int = 0
@ColumnInfo(name = "image")
val image: Int = R.drawable.player_image
var items: MutableList<Item> = mutableListOf()
private set
@ColumnInfo(name = "rank")
var rank: String = "Beginner"
private set
var equipedItem : Tool? = null
private set
//@ColumnInfo(name = "items") Je ne sais pas comment faire pour stocker la liste dans la BDD
var items: MutableList<Item> = mutableListOf()
fun changeRank(){
@ -29,21 +37,6 @@ class Player(var pseudo: String, var xp: Int = 0) {
else -> {"Divine"}
}
}
fun addItem(item: Item) {
val findItem = items.find { it.type.name == item.type.name }
if(findItem!= null){
findItem.stack += item.stack
}
else{
if(item is Tool){
items.add(Tool(type = item.type, stack = item.stack, 4))
}
else{
items.add(Item(type = item.type, stack = item.stack))
}
}
}
fun gainXp(xp: Int) {
this.xp += xp
@ -54,49 +47,44 @@ class Player(var pseudo: String, var xp: Int = 0) {
}
}
fun attack() : Int{
if(equipedItem == null)
return 0
return equipedItem!!.damage
}
fun addItem(item: Item) {
val findItem = items.find { it.type.name == item.type.name }
if(findItem!= null){
println("findItem n: "+findItem.stack+" item nb:"+item.stack)
findItem.stack += item.stack
}
else{items.add(Item(type = item.type, stack = item.stack))}
}
fun hasItem(item: Item) : Boolean{
for (playeritem in items){
if(playeritem.type.name == item.type.name && playeritem.stack >= item.stack){
for (playerItem in items){
if(playerItem.type.name == item.type.name && playerItem.stack >= item.stack){
return true
}
}
return false
}
fun craft(recipe: Recipe, count: Int = 1) : Boolean{
fun craft(recipe: Recipe) : Boolean{
println("test")
for (i in 1..count) {
for (ingredient in recipe.ingredients) {
val searchedItem = items.find { it.type == ingredient.type }
if (searchedItem != null) {
searchedItem.stack -= ingredient.stack
if (searchedItem.stack == 0) {
items.remove(searchedItem)
}
for (ingredient in recipe.ingredients) {
val searchedItem = items.find { it.type.name == ingredient.type.name }
if(searchedItem != null) {
searchedItem.stack -= ingredient.stack
if (searchedItem.stack == 0){
items.remove(searchedItem)
}
println(ingredient.type.name)
if (recipe.item.type.name == "Open Treasure"){
addItem(Generator.generateTreasure())
return true
}
}
println("item:" + recipe.item.stack)
addItem(recipe.item)
}
println("item:"+recipe.item.stack)
addItem(recipe.item)
return true
}
fun equipeItem(item : Item) : Boolean{
if(equipedItem == item) {
println("ca jarte")
equipedItem = null
return false
}
equipedItem = item as Tool
return true
}
}

@ -1,4 +1,5 @@
package com.example.shakecraft.model
import com.example.shakecraft.model.ItemManager.Companion.ITEMS
class RecipeManager {
@ -20,24 +21,28 @@ class RecipeManager {
Item(type = ITEMS.WOODEN_STICK.itemtype, stack = 2),
Item(type = ITEMS.WOODEN_PLANK.itemtype, stack = 2)
), "Objects"),
Recipe(
Item(type = ITEMS.OPEN_TREASURE.itemtype, stack = 1),listOf(
Item(type = ITEMS.TREASURE.itemtype, stack = 1),
Item(type = ITEMS.TREASURE_KEY.itemtype, stack = 1)
), "Objects"),
)
val recipeListTools : List<Recipe> = listOf(
Recipe(
Tool(type = ITEMS.BRONZE_SWORD.itemtype, stack = 1, damage = 4),listOf(
Item(type = ITEMS.BRONZE_SWORD.itemtype, stack = 1),listOf(
Item(type = ITEMS.WOODEN_STICK.itemtype, stack = 5),
Item(type = ITEMS.BRONZE_INGOT.itemtype, stack = 10)
), "Tools"),
Recipe(
Tool(type = ITEMS.WIZARD_STAFF.itemtype, stack = 1, damage = 6),listOf(
Item(type = ITEMS.WIZARD_STAFF.itemtype, stack = 1),listOf(
Item(type = ITEMS.WOODEN_STICK.itemtype, stack = 10),
Item(type = ITEMS.MONSTER_EYE.itemtype, stack = 20),
), "Tools"),
Recipe(
Tool(type = ITEMS.DIAMOND_AXE.itemtype, stack = 1, damage = 8),listOf(
Item(type = ITEMS.DIAMOND_AXE.itemtype, stack = 1),listOf(
Item(type = ITEMS.WOODEN_STICK.itemtype, stack = 5),
Item(type = ITEMS.DIAMOND.itemtype, stack = 10),
@ -59,11 +64,7 @@ class RecipeManager {
)
fun isCraftable(recipe: Recipe, player: Player): Boolean{
fun isCraftable(recipe: Recipe, player :Player): Boolean{
for (ingredient in recipe.ingredients) {
if (!player.hasItem(ingredient)) {
return false
@ -72,16 +73,18 @@ class RecipeManager {
return true
}
fun HowManyCraftable(recipe: Recipe, player: Player): Int{
fun HowManyCraftable(recipe: Recipe, player : Player): Int{
val divisedList = mutableListOf<Int>()
return if (!isCraftable(recipe,player)) 0
if(!isCraftable(recipe,player))
return 0
else{
for(element in recipe.ingredients){
println("cc")
val itemSearch = player.items.find { it.type.name == element.type.name }
if(itemSearch!= null)
divisedList.add(itemSearch.stack / element.stack)
}
divisedList.min()
return divisedList.min()
}
}

@ -1,4 +0,0 @@
package com.example.shakecraft.model
class Tool(type : ItemType, stack: Int,val damage : Int) : Item(type, stack) {
}

@ -1,12 +0,0 @@
package com.example.shakecraft.services
import com.example.shakecraft.data.WeatherResponse
import retrofit2.http.GET
import retrofit2.http.Query
interface OpenWeatherMapService {
@GET("weather")
suspend fun getCurrentWeather(
@Query("q") cityName: String,
@Query("appid") apiKey: String
): WeatherResponse
}

@ -8,56 +8,29 @@ import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.shakecraft.R
import com.example.shakecraft.model.Item
import com.example.shakecraft.model.Player
import com.example.shakecraft.model.Tool
class AdapterInventory(
private val inventory: List<Item>,
private val listener: OnItemLongClickListener,
private val currentPlayer : Player
) :
RecyclerView.Adapter<AdapterInventory.ViewHolder>() {
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view), View.OnLongClickListener {
class AdapterInventory(private val inventory: List<Item>) : RecyclerView.Adapter<AdapterInventory.ViewHolder>() {
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val textView: TextView
val textViewNumber: TextView
var imageView: ImageView
var armorIndicator : ImageView
init {
// Define click listener for the ViewHolder's View
itemView.setOnLongClickListener(this)
textView = view.findViewById(R.id.item_name)
textViewNumber = view.findViewById(R.id.item_stock)
imageView = view.findViewById(R.id.item_image)
armorIndicator = view.findViewById(R.id.armor_indicator)
}
override fun onLongClick(v: View?): Boolean {
val position = adapterPosition
if(position != RecyclerView.NO_POSITION) {
listener.onItemLongClick(position)
}
return true
}
fun bind(item: Item) {
textView.text = item.type.name
textViewNumber.text = item.stack.toString()
imageView.setImageResource(item.type.image)
if (item is Tool) {
println("tool")
armorIndicator.visibility = View.VISIBLE
if(currentPlayer.equipedItem == item) armorIndicator.setImageResource(R.drawable.armor_equiped_icon) else armorIndicator.setImageResource(R.drawable.armor_icon)
}
}
}
interface OnItemLongClickListener{
fun onItemLongClick(position: Int)
}
override fun getItemCount() = inventory.size

@ -0,0 +1,3 @@
package com.example.shakecraft.view.viewholder
class ViewHolderInventory(inflate: Any?) {
}

@ -1,39 +0,0 @@
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
class MainViewModel : ViewModel() {
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
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 929 B

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/black_800"/>
<corners
android:topLeftRadius="5dp"
android:topRightRadius="5dp"
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"/>
<stroke android:width="1dp"
android:color="@color/grey_100" />
</shape>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

@ -1,450 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black_800"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingBottom="10dp"
android:text="@string/home_title"
android:textColor="@color/white"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="15dp"
android:background="@drawable/rounded_border_button"
android:paddingLeft="15dp"
android:paddingRight="15dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2">
<LinearLayout
android:id="@+id/profil_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginVertical="10dp">
<ImageView
android:id="@+id/imageView2"
android:layout_width="60dp"
android:layout_height="95dp"
android:layout_gravity="bottom"
android:contentDescription="@string/landscape"
android:src="@drawable/background" />
<ImageView
android:id="@+id/playerImage"
android:layout_width="50dp"
android:layout_height="80dp"
android:layout_gravity="bottom"
android:contentDescription="Landscape" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="5dp"
android:orientation="vertical">
<EditText
android:id="@+id/pseudoEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pseudo"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Lvl."
android:textColor="@color/grey_300" />
<TextView
android:id="@+id/levelTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2"
android:textColor="@color/grey_300" />
<ProgressBar
android:id="@+id/levelProgressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="5dp"
android:layout_marginHorizontal="10dp"
android:layout_weight="1"
android:max="100"
android:progress="20"
android:progressDrawable="@drawable/custom_level_progressbar" />
<TextView
android:id="@+id/xpTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="349"
android:textColor="@color/white" />
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/"
android:textColor="@color/white" />
<TextView
android:id="@+id/maxXpTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="10dp"
android:text="Rank"
android:textColor="@color/grey_300" />
<TextView
android:id="@+id/rankTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Beginner"
android:textColor="@color/white"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingBottom="15dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/profil_container"
tools:layout_editor_absoluteX="15dp">
<ImageView
android:id="@+id/equipedItemAttack"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="bottom"
android:layout_marginRight="10dp"
android:background="@drawable/background_equiped_item"
android:contentDescription="Landscape"
android:tooltipText="Equiped Weapon" />
<ImageView
android:id="@+id/equipedItemFishing"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="bottom"
android:layout_marginRight="10dp"
android:background="@drawable/background_equiped_item"
android:contentDescription="Landscape"
android:tooltipText="Equiped Fishing Rod" />
<ImageView
android:id="@+id/equipedItemCollect"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="bottom"
android:layout_marginRight="10dp"
android:background="@drawable/background_equiped_item"
android:contentDescription="Landscape"
android:tooltipText="Equiped Tool" />
<ImageView
android:id="@+id/equipedItemArmor"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="bottom"
android:layout_marginRight="10dp"
android:background="@drawable/background_equiped_item"
android:contentDescription="Landscape"
android:tooltipText="Equiped Armor" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<ScrollView
android:id="@+id/scroll_activties"
android:layout_width="220dp"
android:layout_height="200dp"
android:layout_marginStart="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/constraintLayout"
app:layout_constraintTop_toBottomOf="@+id/textView2">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/buttonForge"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="10dp"
android:background="@drawable/rounded_border_button"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/constraintLayout">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/imageView2"
android:layout_width="40dp"
android:layout_height="50dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:src="@drawable/ic_anvil" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ancient Forge"
android:textColor="@color/white"
android:textStyle="bold" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Craft ever more powerful tools."
android:textColor="@color/grey_300"
android:textSize="11sp" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/buttonCollect"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="10dp"
android:background="@drawable/rounded_border_button"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/buttonForge">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/imageView2"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:src="@drawable/ic_tree" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pleasant Forest"
android:textColor="@color/white"
android:textStyle="bold" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Collect ressources to became powerfull."
android:textColor="@color/grey_300"
android:textSize="11sp" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/buttonBoss"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="10dp"
android:background="@drawable/rounded_border_button"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/buttonCollect">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/imageView2"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:src="@drawable/ic_key" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dungeon"
android:textColor="@color/white"
android:textStyle="bold" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Defeat boss to gain Mystic rewards."
android:textColor="@color/grey_300"
android:textSize="11sp" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
<LinearLayout
android:id="@+id/event_container"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="20dp"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/scroll_activties"
app:layout_constraintTop_toBottomOf="@+id/textView2">
<ImageView
android:id="@+id/event_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:clickable="true"
android:maxWidth="200dip"
android:scaleType="centerCrop"
android:src="@drawable/event_message"
android:visibility="visible">
</ImageView>
<ImageView
android:id="@+id/buttonFishing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:clickable="true"
android:visibility="gone"
android:maxWidth="200dip"
android:scaleType="centerCrop"
android:src="@drawable/fishing_event">
</ImageView>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -27,8 +27,7 @@
android:id="@+id/fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="63dp"
android:layout_height="725dp"
app:defaultNavHost="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"

@ -6,7 +6,7 @@
android:layout_height="match_parent"
android:background="@drawable/backgroundboss"
android:scaleType="center"
tools:context=".BossFragment">
tools:context=".fragment.BossFragment">
<FrameLayout
android:id="@+id/frameLayout"

@ -6,7 +6,7 @@
android:layout_height="match_parent"
android:background="@drawable/backgroundforest2"
android:scaleType="center"
tools:context=".CollectFragment">
tools:context=".fragment.CollectFragment">
<FrameLayout
android:id="@+id/frameLayout"

@ -6,7 +6,7 @@
android:layout_height="match_parent"
android:background="@color/black_800"
android:scaleType="center"
tools:context=".CollectFragment">
tools:context=".fragment.CollectFragment">
<FrameLayout
android:id="@+id/frameLayout"
@ -24,24 +24,24 @@
android:id="@+id/backbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:layout_gravity="left|center_vertical"
android:focusable="true"
android:text="@string/ancient_forge"
android:drawableStart="@drawable/back"
android:drawableTint="@color/blue"
android:text="Ancient Forge"
android:textColor="@color/blue"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:drawableStartCompat="@drawable/back"
app:drawableTint="@color/blue" />
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/recipe"
android:text="Recipe"
android:textColor="@color/white"
android:textSize="16sp"
android:textStyle="bold"
@ -63,7 +63,6 @@
app:layout_constraintTop_toBottomOf="@+id/frameLayout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -72,32 +71,14 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/item_image"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/item_recipe_background"
android:contentDescription="@string/image_of_item"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/wooden_stick" />
<TextView
android:id="@+id/craftValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:text="1"
android:paddingRight="2dp"
android:textColor="@color/white" />
</androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
android:id="@+id/item_image"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/item_recipe_background"
android:contentDescription="image of item"
app:srcCompat="@drawable/wooden_stick" />
<TextView
@ -149,34 +130,19 @@
</LinearLayout>
<Button
android:id="@+id/buttonForgeMax"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginBottom="5dp"
android:backgroundTint="@color/button_background_color"
android:text="FORGE MAX"
android:textColor="@color/white"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/buttonForge"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.473"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/buttonForge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginBottom="10dp"
android:backgroundTint="@color/button_background_color"
android:text="Forge"
android:textColor="@color/white"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="parent"
android:backgroundTint="@color/button_background_color"
android:textColor="@color/white"/>
<LinearLayout
android:layout_width="match_parent"
@ -184,7 +150,7 @@
android:layout_marginBottom="10dp"
android:gravity="center"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="@+id/buttonForgeMax"
app:layout_constraintBottom_toTopOf="@+id/buttonForge"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:background="@drawable/craftable_background"

@ -6,7 +6,7 @@
android:layout_height="match_parent"
android:background="@color/black_800"
android:scaleType="center"
tools:context=".CollectFragment">
tools:context=".fragment.CollectFragment">
<FrameLayout
android:id="@+id/frameLayout"
@ -14,20 +14,20 @@
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="50dp"
android:paddingBottom="30dp"
android:paddingBottom="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/RecipeScroll">
android:layout_marginBottom="20dp">
<TextView
android:id="@+id/backbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:layout_gravity="left|center_vertical"
android:focusable="true"
app:drawableStartCompat="@drawable/back"
app:drawableTint="@color/blue"
android:drawableStart="@drawable/back"
android:drawableTint="@color/blue"
android:text="Home"
android:textColor="@color/blue"
android:textSize="16sp"
@ -51,108 +51,96 @@
</FrameLayout>
<androidx.core.widget.NestedScrollView
<ScrollView
android:id="@+id/RecipeScroll"
android:layout_width="match_parent"
android:layout_height="4294967294dp"
android:layout_height="635dp"
android:paddingHorizontal="10dp"
app:layout_constraintTop_toBottomOf="@id/frameLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
>
app:layout_constraintTop_toBottomOf="@+id/frameLayout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="10dp"
android:background="@drawable/recipelistcard"
android:orientation="vertical"
android:paddingBottom="10dp">
<TextView
android:background="@drawable/recipelistcard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginVertical="10dp"
android:paddingBottom="10dp">
<TextView
android:paddingTop="20dp"
android:paddingLeft="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:paddingTop="20dp"
android:text="Objects"
android:textSize="17dp"
android:textColor="@color/grey_400"
android:textSize="17sp"
android:textStyle="bold" />
android:textStyle="bold"
android:text="Objects"/>
<androidx.recyclerview.widget.RecyclerView
android:overScrollMode="never"
android:id="@+id/RecyclerviewObjects"
android:layout_marginHorizontal="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:listitem="@layout/list_recipe"
tools:itemCount="3"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/RecyclerviewObjects"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:overScrollMode="never"
tools:itemCount="3"
tools:listitem="@layout/list_recipe" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:background="@drawable/recipelistcard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="10dp"
android:background="@drawable/recipelistcard"
android:orientation="vertical"
android:layout_marginVertical="10dp"
android:paddingBottom="10dp">
<TextView
android:paddingTop="20dp"
android:paddingLeft="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="20dp"
android:paddingTop="20dp"
android:text="Tools"
android:textSize="17dp"
android:textColor="@color/grey_400"
android:textSize="17sp"
android:textStyle="bold" />
android:textStyle="bold"
android:text="Tools"/>
<androidx.recyclerview.widget.RecyclerView
android:overScrollMode="never"
android:id="@+id/RecyclerviewTools"
android:layout_marginHorizontal="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:overScrollMode="never"
tools:itemCount="3"
tools:listitem="@layout/list_recipe" />
tools:listitem="@layout/list_recipe"
tools:itemCount="3"/>
</LinearLayout>
<LinearLayout
android:background="@drawable/recipelistcard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="10dp"
android:background="@drawable/recipelistcard"
android:orientation="vertical"
android:layout_marginVertical="10dp"
android:paddingBottom="10dp">
<TextView
android:paddingTop="20dp"
android:paddingLeft="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="20dp"
android:paddingTop="20dp"
android:text="Blacksmithing"
android:textSize="17dp"
android:textColor="@color/grey_400"
android:textSize="17sp"
android:textStyle="bold" />
android:textStyle="bold"
android:text="Blacksmithing"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/RecyclerviewBlacksmithing"
android:overScrollMode="never"
android:layout_marginHorizontal="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:overScrollMode="never"
tools:itemCount="3"
tools:listitem="@layout/list_recipe"/>
tools:listitem="@layout/list_recipe"
tools:itemCount="3"/>
</LinearLayout>
@ -161,6 +149,7 @@
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -66,11 +66,11 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_margin="15dp"
android:orientation="vertical">
<EditText
android:id="@+id/pseudoEditText"
<TextView
android:id="@+id/pseudoTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pseudo"
@ -149,48 +149,6 @@
android:textColor="@color/white"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/equipedItemAttack"
android:tooltipText="Equiped Weapon"
android:layout_gravity="bottom"
android:background="@drawable/background_equiped_item"
android:layout_width="30dp"
android:layout_height="30dp"
android:contentDescription="Landscape"
android:layout_marginRight="10dp"/>
<ImageView
android:tooltipText="Equiped Fishing Rod"
android:id="@+id/equipedItemFishing"
android:layout_gravity="bottom"
android:background="@drawable/background_equiped_item"
android:layout_width="30dp"
android:layout_height="30dp"
android:contentDescription="Landscape"
android:layout_marginRight="10dp"/>
<ImageView
android:id="@+id/equipedItemCollect"
android:tooltipText="Equiped Tool"
android:layout_gravity="bottom"
android:background="@drawable/background_equiped_item"
android:layout_width="30dp"
android:layout_height="30dp"
android:contentDescription="Landscape"
android:layout_marginRight="10dp"/>
<ImageView
android:id="@+id/equipedItemArmor"
android:tooltipText="Equiped Armor"
android:layout_gravity="bottom"
android:background="@drawable/background_equiped_item"
android:layout_width="30dp"
android:layout_height="30dp"
android:contentDescription="Landscape"
android:layout_marginRight="10dp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
@ -300,7 +258,7 @@
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Collect ressources to became powerfull."
android:text="Craft ever more powerful tools."
android:textColor="@color/grey_300"
android:textSize="11sp" />
</LinearLayout>
@ -356,7 +314,7 @@
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Defeat boss to gain Mystic rewards."
android:text="Craft ever more powerful tools."
android:textColor="@color/grey_300"
android:textSize="11sp" />
</LinearLayout>
@ -364,51 +322,6 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:orientation="vertical"
android:id="@+id/event_container"
android:layout_height="200dp"
android:gravity="center_horizontal"
android:visibility="visible"
android:layout_width="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:paddingBottom="20dp">
<ImageView
android:id="@+id/event_message"
android:visibility="visible"
android:clickable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="300dip"
android:src="@drawable/event_message"
android:scaleType="centerCrop"
android:adjustViewBounds ="true">
</ImageView>
<ImageView
android:id="@+id/buttonFishing"
android:visibility="gone"
android:clickable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="380dip"
android:src="@drawable/fishing_event"
android:scaleType="centerCrop"
android:adjustViewBounds ="true">
</ImageView>
</LinearLayout>

@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black_800"
tools:context=".InventoryFragment">
tools:context=".fragment.InventoryFragment">
<TextView
android:id="@+id/textView2"

@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black_800"
tools:context=".PlusFragment">
tools:context=".fragment.PlusFragment">
<TextView
android:id="@+id/textView2"

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
@ -8,7 +9,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="5dp">
android:layout_marginTop="10dp">
<LinearLayout
android:layout_width="match_parent"
@ -19,7 +20,6 @@
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:contentDescription="@string/lib_name"
android:id="@+id/item_image"
android:layout_width="60dp"
android:layout_height="60dp"
@ -28,7 +28,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@ -40,13 +39,6 @@
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textStyle="bold" />
<ImageView
android:id="@+id/armor_indicator"
android:visibility="gone"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_marginLeft="5dp" />
<View
android:layout_width="wrap_content"

@ -8,7 +8,7 @@
<fragment
android:id="@+id/bossFragment"
android:name="com.example.shakecraft.BossFragment"
android:name="com.example.shakecraft.fragment.BossFragment"
android:label="fragment_boss"
tools:layout="@layout/fragment_boss" >
<action
@ -20,7 +20,7 @@
</fragment>
<fragment
android:id="@+id/collectFragment"
android:name="com.example.shakecraft.CollectFragment"
android:name="com.example.shakecraft.fragment.CollectFragment"
android:label="fragment_collect"
tools:layout="@layout/fragment_collect" >
<action
@ -33,26 +33,22 @@
<fragment
android:id="@+id/plusFragment"
android:name="com.example.shakecraft.PlusFragment"
android:name="com.example.shakecraft.fragment.PlusFragment"
android:label="fragment_plus"
tools:layout="@layout/fragment_plus" />
<fragment
android:id="@+id/inventoryFragment"
android:name="com.example.shakecraft.InventoryFragment"
android:name="com.example.shakecraft.fragment.InventoryFragment"
android:label="fragment_inventory"
tools:layout="@layout/fragment_inventory" />
<fragment
android:id="@+id/homeFragment"
android:name="com.example.shakecraft.HomeFragment"
android:name="com.example.shakecraft.fragment.HomeFragment"
android:label="HomeFragment" >
<action
android:id="@+id/action_homeFragment_to_collectFragment"
app:destination="@id/collectFragment"
app:enterAnim="@android:anim/fade_in"
app:popUpTo="@id/homeFragment"
app:popUpToInclusive="true"
app:popUpToSaveState="true"
app:restoreState="true" />
app:enterAnim="@android:anim/fade_in" />
<action
android:id="@+id/action_homeFragment_to_bossFragment"
app:destination="@id/bossFragment"
@ -63,7 +59,7 @@
</fragment>
<fragment
android:id="@+id/forgeFragment"
android:name="com.example.shakecraft.ForgeFragment"
android:name="com.example.shakecraft.fragment.ForgeFragment"
android:label="ForgeFragment" >
<action
android:id="@+id/action_forgeFragment_to_homeFragment"
@ -77,7 +73,7 @@
</fragment>
<fragment
android:id="@+id/craftFragment"
android:name="com.example.shakecraft.CraftFragment"
android:name="com.example.shakecraft.fragment.CraftFragment"
android:label="CraftFragment" >
<action
android:id="@+id/action_craftFragment_to_forgeFragment"

@ -6,7 +6,4 @@
<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>

@ -4,4 +4,4 @@ plugins {
id 'com.android.library' version '7.4.0' apply false
id 'org.jetbrains.kotlin.android' version '1.7.21' apply false
id "org.sonarqube" version "3.4.0.2513"
}
}
Loading…
Cancel
Save