Mobius
Would you like to react to this message? Create an account in a few clicks or log in to continue.

MultiSellEntry.java have problem

Go down

MultiSellEntry.java have problem Empty MultiSellEntry.java have problem

Post by lineageno1 24/11/14, 10:51 pm

It handling incorrect chance, and heavy
I revised this

Code:
public List<MultiSellIngredient> getProduction(boolean isNew)
   {
      if (isNew)
      {
         MultiSellIngredient req = null;
         int max = 0;
         
         loop: for (int i = 0; i < _production.size(); i++)
         {
            if ((req == null))
            {
               if (Rnd.chance(_production.get(i).getChance()))
               {
                  req = _production.get(i);
               }
               else if (_production.get(max).getChance() < _production.get(i).getChance())
               {
                  max = i;
               }
            }
            else
            {
               break loop;
            }
         }
         if (req == null)
         {
            req = _production.get(max);
         }
         List<MultiSellIngredient> rqa = new ArrayList<>(1);
         rqa.add(req);
         return rqa;
      }
      return _production;
   }

lineageno1
Vassal
Vassal

Posts : 1
Join date : 2014-11-24

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum