src/scripts/combat.js
/**
 * call this onVictory to grab loot & XP from Mobs
 */
call this onVictory to grab loot & XP from Mobs
call this onVictory to grab loot & XP from Mobs
fetchLoot(){ 
  let s=window.story.state;
  let msg='';
  let XP=0, maxLevel = 0, _rnd=_.random(0,100);
  for (el of s.combat.playerParty) {
    maxLevel = Math.max(maxLevel,el.level);
  }
  for(el of s.combat.enemyParty) {
    for(var i = el.loot.length-1;i>=0;i--) {
      if(_rnd<=el.loot[i].chance) {
        msg+= el.loot[i].amount+'x '+el.loot[i].id+' ';
        window.gm.player.changeInventory(window.gm.ItemsLib[el.loot[i].id](),el.loot[i].amount);
      }
    }
    XP+=Math.floor(el.baseXPReward* Math.min(3,Math.max(0,1+(el.level-maxLevel)*0.25)));
  }
  msg = '</br>You got some loot: '+window.gm.util.formatNumber(XP,0) +'XP '+msg+'</br>';
  for (el of s.combat.playerParty) {
    el.addXP(XP);  
  }
  return(msg);
}
fetchLoot ( ) { let s = window . story . state ; let msg = '' ; let XP = 0 , maxLevel = 0 , _rnd = _ . random ( 0 , 100 ) ; for ( el of s . combat . playerParty ) { maxLevel = Math . max ( maxLevel , el . level ) ; } for ( el of s . combat . enemyParty ) { for ( var i = el . loot . length - 1 ; i >= 0 ; i -- ) { if ( _rnd <= el . loot [ i ] . chance ) { msg += el . loot [ i ] . amount + 'x ' + el . loot [ i ] . id + ' ' ; window . gm . player . changeInventory ( window . gm . ItemsLib [ el . loot [ i ] . id ] ( ) , el . loot [ i ] . amount ) ; } } XP += Math . floor ( el . baseXPReward * Math . min ( 3 , Math . max ( 0 , 1 + ( el . level - maxLevel ) * 0.25 ) ) ) ; } msg = '</br>You got some loot: ' + window . gm . util . formatNumber ( XP , 0 ) + 'XP ' + msg + '</br>' ; for ( el of s . combat . playerParty ) { el . addXP ( XP ) ; } return ( msg ) ; }
call this onVictory to grab loot & XP from Mobs
call this onVictory to grab loot & XP from Mobs
//if you are victorious: grant XP & transfer Loot to player  //XP reduced/increased if your level is bigger/smaller then foes by 25% per level //all get the same?