Compare commits

..

91 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
Lucas Delanier a851991274 little arrangements to make the code more kotlin spirit ⚗️
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier 218e85d571 add max craft button 🎉
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier 640950bc50 save the currentboss in tthe viewmodel 🎉
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier 35fd67cbcf viewModel to save state
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier bf752264ef Merge branch 'OpenWeatherApi'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier b04739859f merge api
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier 509506ebb8 clean code smells
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier 3b1bcc6fcf editText binding twoWay on pseudo of currentplayer
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier 0d2d21832e adaptive homepage for landscape orientation
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier 6635825713 add fishing event notification on home page
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier bb0b05ed91 fix forge responsive widget
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier 2b44820d67 add retrofit call weatherapi
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier ab0f8a0462 clean master
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier c6341f7e1a new slot on main page for equiped items and redirect to root 📈
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier f21502c844 new class Tool for equipable item 🔨
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier 2342ca782b Merge remote-tracking branch 'origin/master'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier 30d4e15db5 add plus fragment and wiki button redirect to codefirst repository 🎉
2 years ago
Lucas Delanier dcc94a9845 add plus fragment and wiki button redirect to codefirst repository 🎉
2 years ago
Lucas DELANIER a0cb8ac7d8 Mise à jour de 'README.md'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas DELANIER 53ed556ae3 Transférer les fichiers vers 'Documentations'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier a78a234fde Merge remote-tracking branch 'origin/master'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier 6ac14814db Add player image on home screen and color to indicate not enough resource to craft 🎥
2 years ago
Lucas Delanier 114f329337 Add player image on home screen and color to indicate not enough resource to craft 🎥
2 years ago
Lucas DELANIER 6b7573e4c8 Mise à jour de 'README.md'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier 8c57e59803 Merge remote-tracking branch 'origin/master'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier 478f6aca78 delete test unit
2 years ago
Lucas DELANIER 80ad7fbd24 Mise à jour de 'README.md'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier cb2bc3d313 code smells fix
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier 8baaf3ec96 fix leveling 🔐
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier cb32555325 implement flyweight design pattern 👦
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier b7c8cad9d2 implement flyweight design pattern :pinched_fingers: 👦
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier e3451ca8f4 reduce code smells 🧹
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas DELANIER c110039df8 Mise à jour de 'README.md'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas DELANIER 333a1936fd Mise à jour de 'README.md'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas DELANIER 4d6610626a Mise à jour de 'README.md'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas DELANIER 4904be1a3b Mise à jour de 'README.md'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas DELANIER be8265e0e1 Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas DELANIER 52d227c9b6 Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 4c5d15b10a Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER afd2d59f0c Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 84acd70ecc Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 5155f7c967 Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 82295f2b20 Mise à jour de '.drone.yml'
continuous-integration/drone/push Build encountered an error Details
2 years ago
Lucas DELANIER e501ee30bc Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 07d4bd6e00 Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 7094a2ffca Mise à jour de '.drone.yml'
continuous-integration/drone/push Build encountered an error Details
2 years ago
Lucas DELANIER 055675efe2 Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 33dea9b66c Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER a46cf4fe0e Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 8f1a2da261 Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 1af3ba7653 Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 1082fe450a Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER ec9d6916a7 Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 851e78a884 Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 4c645f15c3 Mise à jour de '.drone.yml'
continuous-integration/drone/push Build encountered an error Details
2 years ago
Lucas DELANIER 893d54dc3e Mise à jour de '.drone.yml'
continuous-integration/drone/push Build encountered an error Details
2 years ago
Lucas DELANIER 90ee24610a Mise à jour de '.drone.yml'
continuous-integration/drone/push Build encountered an error Details
2 years ago
Lucas DELANIER d1794f73de Mise à jour de '.drone.yml'
continuous-integration/drone/push Build encountered an error Details
2 years ago
Lucas DELANIER abe272a99a Mise à jour de 'ShakeAndCraft/build.gradle'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas DELANIER 8be865cf6d Ajouter '.drone.yml'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier 9d38ca5150 problems solved (thx armure) 🛡️
2 years ago
Lucas Delanier a411caadca test to manage problems with stack
2 years ago
Lucas Delanier aa6e3afcb0 Recipe working but with a little issue when add to inventory x2 items :(
2 years ago
Lucas Delanier 5cd26ecbac Recipe working but with a little issue when add to inventory x2 items :(
2 years ago
Lucas Delanier 2d046ac235 fix full screen mode by adding onresume to mainactivity 💡
2 years ago
Lucas Delanier 4c379f05ce Ancient forge is now available with his recipes 🔨🔧
2 years ago
Lucas Delanier 7c4b6cb148 Clean the code in function for better maintenance 💅
2 years ago
Lucas Delanier 64011ba3a0 test
2 years ago
Lucas Delanier 5505a906da Change of the repository structure
2 years ago
Lucas Delanier e9122a8671 Change of the repository structure
2 years ago
Lucas Delanier 61d6b5ae32 add drawable missing
2 years ago
Lucas Delanier 54e9d787bd add recipe constructor sleep now 🌔
2 years ago
Lucas Delanier 3fc5cf9a5a Merge remote-tracking branch 'origin/master'
2 years ago
Lucas Delanier 2e6192f967 fix bugs
2 years ago
Lucas DELANIER 8fa9f57117 Mise à jour de 'README.md'
2 years ago
Lucas DELANIER f19a3c9fcd Mise à jour de 'README.md'
2 years ago
Lucas Delanier 8aa241e9b4 custom item loot for each boss with little animaton on the boss
2 years ago
Lucas Delanier 519439785e custom xp reward following with boss and witch item is loot 🔥
2 years ago
Lucas Delanier 63b91ab270 merge
2 years ago

@ -0,0 +1,24 @@
kind: pipeline
type: docker
name: ShakeAndCraft
trigger:
event:
- push
steps:
- name: code-analysis
image: openjdk:8-jdk
environment:
SONAR_TOKEN:
from_secret: SONAR_TOKEN
settings:
sources: ./src/
commands:
- export SONAR_SCANNER_VERSION=4.7.0.2747
- export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
- curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
- unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
- export PATH=$SONAR_SCANNER_HOME/bin:$PATH
- export SONAR_SCANNER_OPTS="-server"
- sonar-scanner -D sonar.projectKey=ShakeAndCraft -D sonar.sources=. -D sonar.host.url=https://codefirst.iut.uca.fr/sonar

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

@ -1,14 +1,23 @@
<p align="center">
<img src="https://codefirst.iut.uca.fr/git/lucas.delanier/ShakeAndCraft/raw/branch/master/Documentations/banner-shakeandcraft.png" />
<img src="https://codefirst.iut.uca.fr/git/lucas.delanier/ShakeAndCraft/raw/branch/master/Documentations/banner.png" />
</p>
![Kotlin](https://img.shields.io/badge/Kotlin-7F52FF.svg?style=for-the-badge&logo=Kotlin&logoColor=white)
![Android Studio](https://img.shields.io/badge/Android%20Studio-3DDC84.svg?style=for-the-badge&logo=Android-Studio&logoColor=white)
![Android](https://img.shields.io/badge/Android-3DDC84.svg?style=for-the-badge&logo=Android&logoColor=white)
![Android](https://img.shields.io/badge/Android-3DDC84.svg?style=for-the-badge&logo=Android&logoColor=white)</br>
[![Maintainability Rating](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=ShakeAndCraft&metric=sqale_rating&token=bb717076471bf71ba25b805c0b6ad18e4ae5c047)](https://codefirst.iut.uca.fr/sonar/dashboard?id=ShakeAndCraft)
[![Security Rating](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=ShakeAndCraft&metric=security_rating&token=bb717076471bf71ba25b805c0b6ad18e4ae5c047)](https://codefirst.iut.uca.fr/sonar/dashboard?id=ShakeAndCraft)
[![Reliability Rating](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=ShakeAndCraft&metric=reliability_rating&token=bb717076471bf71ba25b805c0b6ad18e4ae5c047)](https://codefirst.iut.uca.fr/sonar/dashboard?id=ShakeAndCraft)
[![Vulnerabilities](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=ShakeAndCraft&metric=vulnerabilities&token=bb717076471bf71ba25b805c0b6ad18e4ae5c047)](https://codefirst.iut.uca.fr/sonar/dashboard?id=ShakeAndCraft)
[![Code Smells](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=ShakeAndCraft&metric=code_smells&token=bb717076471bf71ba25b805c0b6ad18e4ae5c047)](https://codefirst.iut.uca.fr/sonar/dashboard?id=ShakeAndCraft)
[![Bugs](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=ShakeAndCraft&metric=bugs&token=bb717076471bf71ba25b805c0b6ad18e4ae5c047)](https://codefirst.iut.uca.fr/sonar/dashboard?id=ShakeAndCraft)
[![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.
## :floppy_disk: FEATURES
@ -25,23 +34,42 @@ 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">
<img src="https://codefirst.iut.uca.fr/git/lucas.delanier/ShakeAndCraft/raw/branch/master/Documentations/overview-shakeandcraft.png" />
</p>
## :wrench: SUPPORT
En cas de problème lors de l'utilisation de l'application, vous pouvez nous contacer aux adresses suivantes :
Lucas Delanier : **lucas.delanier@etu.uca.fr** </br>
Théo Renaud : **Theo.RENAUD@etu.uca.fr**
![](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png)
## ✨ Contributors
@ -49,6 +77,9 @@ Lucas Delanier : **lucas.delanier@etu.uca.fr** </br>
<a href = "https://codefirst.iut.uca.fr/git/lucas.delanier">
<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="50px">
</a>
<a href = "https://codefirst.iut.uca.fr/git/theo.renaud">
<img src ="https://codefirst.iut.uca.fr/git/avatars/af9299d66a9a0bf7be17f8dc156f67b9?size=870" height="50px">
</a>

@ -7,11 +7,4 @@
<component name="ProjectType">
<option name="id" value="Android" />
</component>
<component name="VisualizationToolProject">
<option name="state">
<ProjectState>
<option name="scale" value="0.2" />
</ProjectState>
</option>
</component>
</project>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

Before

Width:  |  Height:  |  Size: 254 B

After

Width:  |  Height:  |  Size: 254 B

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Before

Width:  |  Height:  |  Size: 593 KiB

After

Width:  |  Height:  |  Size: 593 KiB

@ -17,6 +17,7 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
@ -32,19 +33,37 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
}
packagingOptions {
exclude 'META-INF/atomicfu.kotlin_module'
}
}
apply plugin: 'kotlin-kapt'
dependencies {
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 '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'
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.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
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"
}

@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-feature android:name="android.hardware.sensor.accelerometer" />
<application
android:allowBackup="true"
@ -12,9 +13,6 @@
android:supportsRtl="true"
android:theme="@style/Theme.ShakeCraft"
tools:targetApi="31">
<activity
android:name=".CollectActivity"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="true">

Before

Width:  |  Height:  |  Size: 172 KiB

After

Width:  |  Height:  |  Size: 172 KiB

@ -0,0 +1,186 @@
package com.example.shakecraft
import android.content.Context
import android.content.pm.ActivityInfo
import android.hardware.Sensor
import android.hardware.SensorEvent
import android.hardware.SensorEventListener
import android.hardware.SensorManager
import android.os.Bundle
import android.os.Vibrator
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.Animation
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.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
class BossFragment() : Fragment() {
private lateinit var sensorManager: SensorManager
private lateinit var accelerometer: Sensor
private lateinit var accelerometerEventListener: SensorEventListener
private lateinit var progressBar: ProgressBar
private lateinit var image: ImageView
private lateinit var buttonCollect: TextView
private lateinit var recyclerView: RecyclerView
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 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)
// Set up RecyclerView for boss loot
setUpRecyclerView(view)
// Set up accelerometer listener
viewModel.currentPlayer.value?.let { setUpAccelerometerListener(view, it) }
// Set up activity orientation
setUpActivityOrientation()
// Return fragment view
return view
}
private fun initializeViews(view: View) {
progressBar = view.findViewById(R.id.progressBar)
image = view.findViewById(R.id.imageBoss)
buttonCollect = view.findViewById<TextView>(R.id.backbutton)
buttonCollect.setOnClickListener{
findNavController().navigate(R.id.action_bossFragment_to_homeFragment)
}
}
private fun setUpBoss(boss: Boss) {
progressBar.max = boss.maxlife
progressBar.progress = boss.life.toInt()
image.setImageResource(boss.image)
// Create scale animation for boss image
val scaleAnimation = ScaleAnimation(
1.2f, // from 1.2 to 1.0
1.0f,
1.2f,
1.0f,
Animation.RELATIVE_TO_SELF,
0.5f,
Animation.RELATIVE_TO_SELF,
0.5f
)
scaleAnimation.duration = 1000 // lasts 1 second
scaleAnimation.repeatCount = Animation.INFINITE // repeat indefinitely
scaleAnimation.repeatMode = Animation.REVERSE // reverse animation direction
image.startAnimation(scaleAnimation)
}
private fun setUpRecyclerView(view: View) {
recyclerView = view.findViewById(R.id.recyclerviewBossLoot)
with(recyclerView) {
layoutManager = LinearLayoutManager(view.context)
adapter = AdapterBossLoot(viewModel.currentBoss.possibleLoot)
}
}
private fun setUpActivityOrientation(){
val activity = requireActivity()
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}
private fun displayToast(view: View, item: Item){
val toastView = view.findViewById<View>(R.id.toast)
val lootImage = toastView.findViewById<ImageView>(R.id.imageViewLoot)
val lootName = toastView.findViewById<TextView>(R.id.nameLoot)
val xpReward = toastView.findViewById<TextView>(R.id.xpRewarded)
toastView.visibility = View.VISIBLE
lootImage.setImageResource(item.type.image)
lootName.text = item.type.name
xpReward.text = viewModel.currentBoss.xpReward.toString()
toastView.postDelayed({
toastView.visibility = View.GONE
}, 3000)
}
private fun setUpAccelerometerListener(view: View, currentPlayer: Player) {
sensorManager = requireActivity().getSystemService(Context.SENSOR_SERVICE) as SensorManager
accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)
accelerometerEventListener = object : SensorEventListener {
override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) {
// Do nothing
}
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) {
//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)
// Show loot toast view for 3 seconds
displayToast(view,item)
// Spawn new boss and reset progress bar
viewModel.currentBoss = Generator.generateBoss()
setUpBoss(viewModel.currentBoss)
//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()
}
}
}
// Register accelerometer sensor earphone with manager
sensorManager.registerListener(
accelerometerEventListener,
accelerometer,
SensorManager.SENSOR_DELAY_GAME
)
}
override fun onDestroy() {
super.onDestroy()
// Unregister the accelerometer sensor listener when the fragment is destroyed
sensorManager.unregisterListener(accelerometerEventListener)
val activity = requireActivity()
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
}
}

@ -1,6 +1,6 @@
package com.example.shakecraft
import android.annotation.SuppressLint
import android.content.Context
import android.content.pm.ActivityInfo
import android.hardware.Sensor
@ -16,11 +16,16 @@ import android.view.ViewGroup
import android.widget.ImageView
import android.widget.ProgressBar
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
import com.example.shakecraft.data.Stub
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
import kotlin.math.sqrt
@ -30,99 +35,102 @@ class CollectFragment() : Fragment() {
private lateinit var accelerometer: Sensor
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)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
var player = (activity as MainActivity).currentPlayer
// Récupérez une référence à la ProgressBar dans la vue
val view = inflater.inflate(R.layout.fragment_collect, container, false)
// Initialize views
initializeViews(view)
val buttonCollect = view.findViewById<TextView>(R.id.backbutton)
buttonCollect.setOnClickListener{
// Set up accelerometer listener
viewModel.currentPlayer.value?.let { setUpAccelerometerListener(view, it) }
// Set up activity orientation
setUpActivityOrientation()
// Return fragment view
return view
}
private fun initializeViews(view: View) {
progressBar = view.findViewById(R.id.progressBar)
buttonBack = view.findViewById<TextView>(R.id.backbutton)
buttonBack.setOnClickListener{
findNavController().navigate(R.id.action_collectFragment_to_homeFragment)
}
}
private fun setUpActivityOrientation(){
val activity = requireActivity()
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}
private fun displayToast(view: View, item: Item){
val maVue = view.findViewById<View>(R.id.toast)
val image = maVue.findViewById<ImageView>(R.id.imageViewLoot)
val name = maVue.findViewById<TextView>(R.id.nameLoot)
val xp = maVue.findViewById<TextView>(R.id.xpRewarded)
maVue.visibility = View.VISIBLE
image.setImageResource(item.type.image)
name.text = item.type.name
xp.text = item.type.xpReward.toString()
maVue.postDelayed({
maVue.visibility = View.GONE
progressBar = view.findViewById(R.id.progressBar)
}, 3000)
}
private fun setUpAccelerometerListener(view: View, currentPlayer: Player) {
sensorManager = requireActivity().getSystemService(Context.SENSOR_SERVICE) as SensorManager
accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)
// Créez un écouteur de capteur d'accéléromètre pour écouter les secousses
accelerometerEventListener = object : SensorEventListener {
override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) {
// Ne faites rien ici
// Do nothing
}
@SuppressLint("ServiceCast")
override fun onSensorChanged(event: SensorEvent?) {
val acceleration = sqrt(
event!!.values[0].pow(2) + event.values[1].pow(2) + event.values[2].pow(2)
)
val acceleration = sqrt(event!!.values[0].pow(2) + event.values[1].pow(2) + event.values[2].pow(2))
if(progressBar.progress == 100){
val item = Generator.generateLootCollection();
println(item);
player.addItem(item);
progressBar.progress = 0;
//Vibration to signal collect of the resource
val vibrator = context?.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
vibrator.vibrate(100)
// Generate a resource item and XP reward
val item = Generator.generateLootCollection()
viewModel.addItem(item)
currentPlayer.gainXp(item.type.xpReward)
//reset to 0 the progress bar
progressBar.progress = 0
val maVue = view.findViewById<View>(R.id.toast)
val image = maVue.findViewById<ImageView>(R.id.imageViewLoot)
val name = maVue.findViewById<TextView>(R.id.nameLoot)
val xp = maVue.findViewById<TextView>(R.id.xpRewarded)
maVue.visibility = View.VISIBLE
image.setImageResource(item.image)
name.text = item.name
maVue.postDelayed({
maVue.visibility = View.GONE
}, 3000)
// Show loot toast view for 3 seconds
displayToast(view,item)
}
if (acceleration > 40) {
// Le téléphone a été secoué, mettre à jour la barre de chargement ici
progressBar.progress += (acceleration/20).toInt() // Incrémente la progression de la barre de 10 unités
// raise the progress bar based on acceleration value
progressBar.progress += (acceleration/20).toInt()
}
}
}
// Enregistrez l'écouteur de capteur d'accéléromètre
// Register accelerometer sensor earphone with manager
sensorManager.registerListener(
accelerometerEventListener,
accelerometer,
SensorManager.SENSOR_DELAY_GAME
)
// Retournez la vue de fragment
return view
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
val activity = requireActivity()
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}
override fun onDestroy() {
super.onDestroy()
// Désenregistrez l'écouteur de capteur d'accéléromètre lorsque le fragment est détruit
// Unregister the accelerometer sensor listener when the fragment is destroyed
sensorManager.unregisterListener(accelerometerEventListener)
val activity = requireActivity()
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED

@ -0,0 +1,102 @@
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.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.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() {
private lateinit var buttonBack: TextView
private lateinit var recyclerViewMaterials: RecyclerView
private lateinit var recipe: Recipe
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?) {
super.onCreate(savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
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)
})
return view
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
private fun setUpRecyclerView(view: View, currentPlayer: Player) {
recyclerViewMaterials = view.findViewById(R.id.RecyclerviewMaterials)
with(recyclerViewMaterials) {
layoutManager = LinearLayoutManager(view.context)
adapter = AdapterMaterials(recipe.ingredients, currentPlayer)
}
}
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)
}
image = view.findViewById(R.id.item_image)
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.setOnClickListener{
viewModel.craft(recipe)
}
buttonForgeMax.setOnClickListener{
viewModel.craft(recipe, RecipeManager.HowManyCraftable(recipe, currentPlayer))
}
}
}

@ -0,0 +1,84 @@
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.TextView
import androidx.core.os.bundleOf
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
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
private lateinit var recyclerViewTools: RecyclerView
private lateinit var recyclerViewBlacksmithing: RecyclerView
private lateinit var recipe: Recipe
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onItemClick(position: Int, type: String) {
recipe = when(type){
"Objects" -> RecipeManager.recipeListObjects[position]
"Tools" -> RecipeManager.recipeListTools[position]
"Blacksmithing" -> RecipeManager.recipeListBlacksmithing[position]
else -> {RecipeManager.recipeListObjects[position]}
}
val bundle = bundleOf("recipe" to recipe)
findNavController().navigate(R.id.action_forgeFragment_to_craftFragment, bundle)
}
private fun initializeViews(view: View) {
buttonBack = view.findViewById<TextView>(R.id.backbutton)
buttonBack.setOnClickListener{
findNavController().navigate(R.id.action_forgeFragment_to_homeFragment)
}
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_forge, container, false)
// Initialize views
initializeViews(view)
setUpRecyclerView(view, this)
return view
}
private fun setUpRecyclerView(view: View, listener: AdapterRecipe.OnItemClickListener) {
recyclerViewObjects = view.findViewById(R.id.RecyclerviewObjects)
with(recyclerViewObjects) {
layoutManager = LinearLayoutManager(view.context)
adapter = AdapterRecipe(RecipeManager.recipeListObjects, listener)
}
recyclerViewTools = view.findViewById(R.id.RecyclerviewTools)
with(recyclerViewTools) {
layoutManager = LinearLayoutManager(view.context)
adapter = AdapterRecipe(RecipeManager.recipeListTools, listener)
}
recyclerViewBlacksmithing = view.findViewById(R.id.RecyclerviewBlacksmithing)
with(recyclerViewBlacksmithing) {
layoutManager = LinearLayoutManager(view.context)
adapter = AdapterRecipe(RecipeManager.recipeListBlacksmithing, listener)
}
}
}

@ -0,0 +1,124 @@
package com.example.shakecraft
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.model.Player
import com.example.shakecraft.viewmodel.MainViewModel
class HomeFragment : Fragment() {
private lateinit var pseudoEditText : EditText
private lateinit var progressbar : ProgressBar
private lateinit var level : TextView
private lateinit var rank : TextView
private lateinit var maxXp : TextView
private lateinit var xp : TextView
private lateinit var buttonCollect : ConstraintLayout
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 view = inflater.inflate(R.layout.fragment_home,container,false)
// Initialize views
viewModel.currentPlayer.observe(viewLifecycleOwner, Observer {
initializeViews(view, it, isRaining)
})
return view
}
/*fun loadWeatherDate(){
CoroutineScope(Dispatchers.IO).launch {
val
}
}*/
private fun initializeViews(view: View, currentPlayer : Player, isRaining : Boolean) {
progressbar = view.findViewById(R.id.levelProgressBar)
level = view.findViewById(R.id.levelTextView)
rank = view.findViewById(R.id.rankTextView)
maxXp = view.findViewById(R.id.maxXpTextView)
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())
}
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())
}
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())
}
level.text = currentPlayer.level.toString()
rank.text = currentPlayer.rank
xp.text = currentPlayer.xp.toString()
maxXp.text = (currentPlayer.level*100).toString()
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,62 @@
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
)
}
}
}
}

@ -0,0 +1,100 @@
package com.example.shakecraft
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.google.android.material.bottomnavigation.BottomNavigationView
import kotlinx.coroutines.*
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
class MainActivity: AppCompatActivity() {
var isRaining = false
private val model: MainViewModel by viewModels()
@RequiresApi(Build.VERSION_CODES.R)
private fun hideSystemUI() {
WindowCompat.setDecorFitsSystemWindows(window, false)
WindowInsetsControllerCompat(window,
window.decorView.findViewById(android.R.id.content)).let { controller ->
controller.hide(WindowInsetsCompat.Type.systemBars())
controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
}
}
private lateinit var bottomNav : BottomNavigationView
@RequiresApi(Build.VERSION_CODES.R)
override fun onCreate(savedInstanceState: Bundle?) {
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()
// Masquer la barre de navigation et la barre d'état
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_FULLSCREEN
or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
}
}

@ -0,0 +1,45 @@
package com.example.shakecraft
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
class PlusFragment : Fragment() {
private lateinit var buttonWiki : LinearLayout
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
val view = inflater.inflate(R.layout.fragment_plus, container, false)
// Initialize views
setUpRecyclerView(view)
return view
}
private fun setUpRecyclerView(view: View,) {
buttonWiki = view.findViewById(R.id.wikiButton)
buttonWiki.setOnClickListener{
val url = "https://codefirst.iut.uca.fr/git/lucas.delanier/ShakeAndCraft"
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(url)
intent.setPackage("com.android.chrome")
startActivity(intent)
}
}
}

@ -0,0 +1,20 @@
package com.example.shakecraft.data
import com.example.shakecraft.model.*
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))
return currentPlayer
}
}

@ -0,0 +1,19 @@
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
)

@ -0,0 +1,15 @@
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)
}

@ -0,0 +1,16 @@
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)
}

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

@ -1,5 +1,4 @@
package com.example.shakecraft.model
import com.example.shakecraft.R
import kotlin.random.Random
@ -8,10 +7,10 @@ class Generator {
companion object {
fun generateLootCollection(): Item {
val possibleLoot: List<Pair<Item, Double>> = listOf(
Pair(Item(name = "Beech Log", rarity = 0, stack = 1, R.drawable.log2), 0.6),
Pair(Item(name = "Bronze Ore", rarity = 0, stack = 1, R.drawable.bronze_ore), 0.25),
Pair(Item(name = "Iron Ore", rarity = 0, stack = 1, R.drawable.iron_ore), 0.10),
Pair(Item(name = "Diamond", rarity = 0, stack = 1, R.drawable.diamond), 0.05),
Pair(Item(type = ITEMS.BEECH_LOG.itemtype), 0.6),
Pair(Item(type = ITEMS.BRONZE_ORE.itemtype), 0.25),
Pair(Item(type = ITEMS.IRON_ORE.itemtype), 0.10),
Pair(Item(type = ITEMS.DIAMOND.itemtype), 0.05),
)
val rand = Random.nextDouble()
@ -43,11 +42,30 @@ class Generator {
fun generateBoss(): Boss {
val possibleBoss: List<Pair<Boss, Double>> = listOf(
Pair(Boss(name = "Margit the Fell Omen", life = 150, maxlife = 150, image = R.drawable.boss), 0.5),
Pair(Boss(name = "Godrick the Grafted", life = 200, maxlife = 200, image = R.drawable.skeleton), 0.2),
Pair(Boss(name = "Red Wolf of Radagon", life = 250, maxlife = 250, image = R.drawable.halberdier), 0.15),
Pair(Boss(name = "Old Banshee", life = 300, maxlife = 300, image = R.drawable.banshee), 0.10),
Pair(Boss(name = "Margit the Fell Omen", life = 500, maxlife = 500, image = R.drawable.lich), 0.05),
Pair(Boss(name = "Margit the Fell Omen", life = 150.0, 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(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(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(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(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),
)), 0.05),
)
val rand = Random.nextDouble()

@ -0,0 +1,46 @@
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(
val type: ItemType,
var stack: Int = 1,
) : Parcelable {
@PrimaryKey(autoGenerate = true) val id: String = type.name
override fun describeContents(): Int {
return 0
}
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeString(type.name)
parcel.writeInt(type.rarity)
parcel.writeInt(type.image)
parcel.writeInt(type.xpReward)
parcel.writeInt(stack)
}
companion object CREATOR : Parcelable.Creator<Item> {
override fun createFromParcel(parcel: Parcel): Item {
return Item(
ItemType(parcel.readString()!!,parcel.readInt(),
parcel.readInt(),
parcel.readInt(),),
parcel.readInt()
)
}
override fun newArray(size: Int): Array<Item?> {
return arrayOfNulls(size)
}
}
}

@ -0,0 +1,31 @@
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)),
}

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

@ -0,0 +1,102 @@
package com.example.shakecraft.model
import com.example.shakecraft.R
class Player(var pseudo: String, var xp: Int = 0) {
var level: Int = 1
private set
val image: Int = R.drawable.player_image
var items: MutableList<Item> = mutableListOf()
private set
var rank: String = "Beginner"
private set
var equipedItem : Tool? = null
private set
fun changeRank(){
this.rank = when(level){
in 1..2 -> "Beginner"
in 3..5 -> "Intermediate"
in 6..8 -> "Proficient"
in 9..11 -> "Expert"
in 12..14 -> "Master"
in 15..17 -> "Professional"
in 18..19 -> "Champion"
in 20..22 -> "Legend"
in 23..25 -> "Invincible"
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
if (this.xp >= this.level *100){
this.level +=1
this.xp = 0
changeRank()
}
}
fun attack() : Int{
if(equipedItem == null)
return 0
return equipedItem!!.damage
}
fun hasItem(item: Item) : Boolean{
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{
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)
}
}
}
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
}
}

@ -0,0 +1,29 @@
package com.example.shakecraft.model
import android.os.Parcel
import android.os.Parcelable
class Recipe(val item: Item, val ingredients : List<Item>, val type: String) : Parcelable {
override fun describeContents(): Int {
return 0
}
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeParcelable(item, flags)
parcel.writeTypedList(ingredients)
parcel.writeString(type)
}
companion object CREATOR : Parcelable.Creator<Recipe> {
override fun createFromParcel(parcel: Parcel): Recipe {
return Recipe(
parcel.readParcelable(Item::class.java.classLoader)!!,
parcel.createTypedArrayList(Item.CREATOR)!!,
parcel.readString()!!
)
}
override fun newArray(size: Int): Array<Recipe?> {
return arrayOfNulls(size)
}
}
}

@ -0,0 +1,91 @@
package com.example.shakecraft.model
class RecipeManager {
companion object {
val recipeListObjects : List<Recipe> = listOf(
Recipe(
Item(type = ITEMS.WOODEN_STICK.itemtype, stack = 1),listOf(
Item(type = ITEMS.WOODEN_PLANK.itemtype, stack = 2)
), "Objects"),
Recipe(
Item(type = ITEMS.WOODEN_PLANK.itemtype, stack = 3),listOf(
Item(type = ITEMS.BEECH_LOG.itemtype, stack = 1)
), "Objects"),
Recipe(
Item(type = ITEMS.WOODEN_BALL.itemtype, stack = 1),listOf(
Item(type = ITEMS.WOODEN_STICK.itemtype, stack = 2),
Item(type = ITEMS.WOODEN_PLANK.itemtype, stack = 2)
), "Objects"),
)
val recipeListTools : List<Recipe> = listOf(
Recipe(
Tool(type = ITEMS.BRONZE_SWORD.itemtype, stack = 1, damage = 4),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.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.WOODEN_STICK.itemtype, stack = 5),
Item(type = ITEMS.DIAMOND.itemtype, stack = 10),
), "Tools"),
)
val recipeListBlacksmithing : List<Recipe> = listOf(
Recipe(
Item(type = ITEMS.BRONZE_INGOT.itemtype, stack = 1),listOf(
Item(type = ITEMS.BRONZE_ORE.itemtype, stack = 5)
), "Blacksmithing"),
Recipe(
Item(type = ITEMS.IRON_INGOT.itemtype, stack = 1),listOf(
Item(type = ITEMS.IRON_ORE.itemtype, stack = 5)
), "Blacksmithing"),
)
fun isCraftable(recipe: Recipe, player: Player): Boolean{
for (ingredient in recipe.ingredients) {
if (!player.hasItem(ingredient)) {
return false
}
}
return true
}
fun HowManyCraftable(recipe: Recipe, player: Player): Int{
val divisedList = mutableListOf<Int>()
return if (!isCraftable(recipe,player)) 0
else{
for(element in recipe.ingredients){
val itemSearch = player.items.find { it.type.name == element.type.name }
if(itemSearch!= null)
divisedList.add(itemSearch.stack / element.stack)
}
divisedList.min()
}
}
}
}

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

@ -0,0 +1,12 @@
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
}

@ -6,17 +6,16 @@ import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.Adapter
import com.example.shakecraft.R
import com.example.shakecraft.model.Item
import com.example.shakecraft.view.viewholder.ViewHolderInventory
class AdapterInventory(private val inventory: List<Item>) : RecyclerView.Adapter<AdapterInventory.ViewHolder>() {
class AdapterBossLoot(private val possibleLoot: List<Pair<Item, Double>>) : RecyclerView.Adapter<AdapterBossLoot.ViewHolder>() {
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val textView: TextView
val textViewNumber: TextView
val textViewDropRate: TextView
var imageView: ImageView
@ -24,26 +23,27 @@ class AdapterInventory(private val inventory: List<Item>) : RecyclerView.Adapter
// Define click listener for the ViewHolder's View
textView = view.findViewById(R.id.item_name)
textViewNumber = view.findViewById(R.id.item_stock)
textViewDropRate = view.findViewById(R.id.item_stock)
imageView = view.findViewById(R.id.item_image)
}
fun bind(item: Item) {
textView.text = item.name
textViewNumber.text = item.stack.toString()
imageView.setImageResource(item.image)
fun bind(item: Pair<Item, Double>) {
textView.text = item.first.type.name
textViewDropRate.text = (item.second*100).toString()
imageView.setImageResource(item.first.type.image)
}
}
override fun getItemCount() = inventory.size
override fun getItemCount() = possibleLoot.size
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.list_item, parent, false)
.inflate(R.layout.list_loot, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {
val item : Item = inventory[position]
val item : Pair<Item, Double> = possibleLoot[position]
viewHolder.bind(item)
}

@ -0,0 +1,80 @@
package com.example.shakecraft.view.adapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
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 {
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
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.list_item, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {
val item : Item = inventory[position]
viewHolder.bind(item)
}
}

@ -0,0 +1,65 @@
package com.example.shakecraft.view.adapter
import android.graphics.Color
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
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
class AdapterMaterials(private val materials: List<Item>, val currentplayer: Player) : RecyclerView.Adapter<AdapterMaterials.ViewHolder>() {
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val textView: TextView
val textViewNumberNeeded: TextView
val textViewNumberPlayer: TextView
var imageView: ImageView
init {
// Define click listener for the ViewHolder's View
textView = view.findViewById(R.id.item_name)
textViewNumberPlayer = view.findViewById(R.id.numberCurrentPlayer)
textViewNumberNeeded = view.findViewById(R.id.numberNeeded)
imageView = view.findViewById(R.id.item_image)
}
fun bind(item: Item, currentplayer: Player) {
textView.text = item.type.name
val itemSearch = currentplayer.items.find { it.type.name == item.type.name }
textViewNumberNeeded.text = item.stack.toString()
textViewNumberPlayer.text = itemSearch?.stack?.toString() ?: "0"
imageView.setImageResource(item.type.image)
if (itemSearch != null) {
if(item.stack > itemSearch.stack) textViewNumberPlayer.setTextColor(Color.RED) else textViewNumberPlayer.setTextColor(Color.WHITE)
}
else textViewNumberPlayer.setTextColor(Color.RED)
}
}
override fun getItemCount() = materials.size
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.list_craft, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {
val item : Item = materials[position]
viewHolder.bind(item, currentplayer)
}
}

@ -0,0 +1,66 @@
package com.example.shakecraft.view.adapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.shakecraft.R
import com.example.shakecraft.model.Recipe
class AdapterRecipe(
private val recipelist: List<Recipe>,
private val listener: OnItemClickListener
) :
RecyclerView.Adapter<AdapterRecipe.ViewHolder>() {
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view), View.OnClickListener {
val textView: TextView
var imageView: ImageView
init {
// Define click listener for the ViewHolder's View
itemView.setOnClickListener(this)
textView = view.findViewById(R.id.item_name)
imageView = view.findViewById(R.id.item_image)
}
override fun onClick(v: View?) {
val position = adapterPosition
val type = recipelist.first().type
if(position != RecyclerView.NO_POSITION) {
listener.onItemClick(position, type)
}
}
fun bind(recipe: Recipe) {
textView.text = recipe.item.type.name
imageView.setImageResource(recipe.item.type.image)
}
}
interface OnItemClickListener{
fun onItemClick(position: Int, type: String)
}
override fun getItemCount() = recipelist.size
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.list_item, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {
val recipe : Recipe = recipelist[position]
viewHolder.bind(recipe)
}
}

@ -0,0 +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.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
}
}

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!--When the button is not enabled-->
<item android:state_enabled="false" android:color="@color/grey" />
<!--When button is enabled-->
<item android:state_enabled="true" android:color="@color/blue" />
<!--Default Text Color-->
<item android:color="#db402c" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 929 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

@ -0,0 +1,11 @@
<?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>

Before

Width:  |  Height:  |  Size: 573 KiB

After

Width:  |  Height:  |  Size: 573 KiB

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/grey_100" />
</shape>
</item>
<item android:top="1dp" android:bottom="1dp" >
<shape android:shape="rectangle">
<solid android:color="@color/black_800" />
</shape>
</item>
</layer-list>

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="@color/blue" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent" />
</shape>
</item>
</selector>

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 963 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Before

Width:  |  Height:  |  Size: 233 KiB

After

Width:  |  Height:  |  Size: 233 KiB

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

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

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

@ -1,13 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/grey_100" />
</shape>
</item>
<item android:top="2dp" >
<shape android:shape="rectangle">
<solid android:color="@color/black_800" />
</shape>
</item>
</layer-list>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

@ -0,0 +1,4 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/black_800"/>
<item android:drawable="@drawable/roundedreciplistcard"/>
</layer-list>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save