Jump to content

Recommended Posts

Posted

Hello to all,

This time, I'm stuck on an issue with a 'find' request. I have found a turnaround, but I have no idea what's going on, really, and I wish I could understand. My code is the following :

$nbEl = $player->places->count();
$items = $pages->find("template=place|item|equipment, GC<=$player->GC, level<=$player->level, freeActs<=$nbEl")->sort("template, name");

If I explain briefly : the $items should contain the possible elements for a player according to his level and GC (gold coins), and freeActs, i.e. the number of already 'bought' places.

If the 1st line $nbEl returns a number higher than 0, it 'works', I get some items. BUT if the player has not bought any place yet and then $nbEl = 0, $items is... empty whereas it should contain all elements being accessible with a 0 'freeAct' field (and there are many).

I have tried to hard-code 'freeActs<=0', I get no items. 'freeActs<=1', I get some nice results' AND THEN, 'freeActs=0' and it works as expected

So here's my 'workaround' :

	$nbEl = $player->places->count()+1;
$items = $pages->find("template=place|item|equipment, GC<=$player->GC, level<=$player->level, freeActs<$nbEl")->sort("template, name");
	

Note the 'freeActs<$nbEl' instead of 'freeActs<=$nbEl' and the '+1' for $nbEl so not to start at 0... Then, it works as expected !?!?

Does someone have an explanation for this ?

Thanks in advance if you do. And don't hesitate asking me for more details/explanations if you need.

Posted

Is "freeActs" an integer field? If so maybe you need to check this setting:

 2017-10-17_122233.png.f9638b4d776e4108642f548d978e081f.png

I cropped it out of the screenshot but read the setting description for a good explanation of what this setting is for.

Posted

It is an integer and I've checked the setting and intentionally set it to 'Yes' because my freeActs field had no value in some pages and I wanted those pages to be returned. In short, a player being level 1 with no previous activity should have access to items having level 1 set, enough Gold Coins (GC) and 0 previous 'free' actions...

I guess I'm not clearly understanding this yet. I'll go ahead and try to check 'No' and see what's going on, but later during the day.

Thanks for your help @Robin S

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...