Page 1 of 1

Giving random unique item

Posted: Wed Feb 13, 2019 9:52 pm
by ldmarkley
I was trying to expand on the give the player a random item so that it would give the player a random unique item. In the game we're working on we have 36 possible items. In each playthrough the player will only get four of those items and they shouldn't repeat. I've attached my Javascript below. I've gone from the code freezing up my ARIS app to just not giving the player an item. Any suggestions?

Code: Select all

<script type='text/javascript'>
//The next three lines need to stay in to sync with the API
var ARIS = {};
ARIS.ready = function()
  var item_names =
        var i;
        var item_id;
  var itemcount = null;
  var c=0;
  while (itemcount !== 0) {
    if (c++ > 500) {
      console.error("Recursion limit of 500 exceeded!");
      alert("Recursion limit exceeded!");
                i = Math.floor(Math.random()*item_names.length);
                item_id = ARIS.cache.idForItemName(item_names[i]);
                itemcount = ARIS.cache.getItemCount(item_id);
alert (item_id);       
<div id='content'>

Put your text content here!


Re: Giving random unique item

Posted: Tue Feb 19, 2019 6:15 pm
by ldmarkley
So I gave up on the Javascript finally. In spite of all my debugging attempts I could never figure out what it didn't like. The solution I went with was a sort-of-complicated grouping of scenes and using one randomizing script.
Oh well.

Related to the same game was there ever a solution for keeping the map from flashing between plaques? I saw an old post where someone had asked about that but didn't see any solutions.

Re: Giving random unique item

Posted: Thu Feb 21, 2019 9:44 am
by chrish
Sorry for the delay in getting to this. I have a couple ideas but not a ton of help maybe.

There's not a way to debug right in ARIS though you could set up a page to run from Safari and debug there in the web browser. That might not help if the code you're running through ARIS is specific to ARIS. I bet a few teams have had to do something like that, and hopefully can weigh in on the forums. My guess: they start with the Xcode project for ARIS and run it in the simulator, using the debug tools there. For regular Safari, there is a debug menu you can turn on in the Safari settings but I don't know if it applies to web views within apps.

As far as the problem of handing out unique items, to make sure no team gets the same one, the easiest way I can think is to do it with physical tokens rather than Javascript. Just have a few physical cards with different QR codes (or something fancier), and have them handed out to different teams at the start.

Or you could hand them out in order, not randomly, and increment a "world item" to know which one to hand out at any given time. To be a bit more specific:
item: counter. World starts with 0.
Set up a dictionary so that each item you want to give out is indexed with a value for counter.
Every time a team plays, you hand out the corresponding item and then give one counter to the world.
Making the counter a modular number, or something similar, would make it so you don't need to reset it.

Re: Giving random unique item

Posted: Thu Feb 21, 2019 9:46 am
by chrish
For the map flashing, it might depend on how you're sending the player. Do you have one plaque whose continue button sends the player to the new plaque?