Cristiano Magro
2024-12-26 4a01d95d25a6c59e20618365ba675a4d0736080d
logica per l'attacco al mostro
2 files modified
36 ■■■■ changed files
04 - monster slayer game/prj-monster-01-starting-setup/app.js 34 ●●●● patch | view | raw | blame | history
04 - monster slayer game/prj-monster-01-starting-setup/index.html 2 ●●● patch | view | raw | blame | history
04 - monster slayer game/prj-monster-01-starting-setup/app.js
@@ -1,10 +1,28 @@
function getRandomValue(min, max){
    return Math.floor(Math.random() * (max - min)) + min;
}
const app = Vue.createApp({
    data() {
      return {};
  data() {
    return {
      playerHealth: 100,
      monsterHealth: 100,
    };
  },
  computed: {},
  watch: {},
  methods: {
    attackMonster() {
      const attackValue = getRandomValue(5,12);
      this.monsterHealth -= attackValue;
      this.attackPlayer();
    },
    computed: {},
    watch: {},
    methods: {},
  });
  app.mount("#game");
    attackPlayer(){
        const attackValue = getRandomValue(8,15);
        this.playerHealth -= attackValue;
    },
  },
});
app.mount("#game");
04 - monster slayer game/prj-monster-01-starting-setup/index.html
@@ -9,7 +9,7 @@
      rel="stylesheet"
    />
    <link rel="stylesheet" href="styles.css" />
    <script src="https://unpkg.com/vue@next" defer></script>
    <script src="https://unpkg.com/vue@3.4.9/dist/vue.global.js"></script>
    <script src="app.js" defer></script>
  </head>
  <body>