Jump to content

Search the Community

Showing results for tags 'nextuntil'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 1 result

  1. Hello, I'm stuck with a nextUntil() use I can't figure out. The following function works if I use the commented part instead of the last 2 lines (with nextUntil). function checkStreak($player) { // Set Ambassador skill if necessary $ok = 1; $streak = 0; /* $lastEvents = $player->get("name=history")->find("template=event, sort=-date")->not("task.name=donated|donation|absent, limit=10"); */ /* foreach ($lastEvents as $e) { */ /* if ($ok == 1) { */ /* if ($e->task->HP >= 0) { */ /* $streak++; */ /* } else { */ /* $ok = 0; */ /* } */ /* } */ /* } */ $lastEvent = $player->get("name=history")->children("template=event, sort=-date")->not("task.name=donated|donation|absent")->first(); $streak = $lastEvent->nextUntil("task.HP<0")->count(); return $streak; } But I know it's ugly and... I sometimes wish I had a tutor to help me improve my coding style In words, what I'm doing is : - Check the last events recorded for a 'player' - I want to check the number of positive events in a row (before a negative occurs) - My function gets the last 10 events (the limit to get a bonus) and checks each one, but stops if it encounters a negative event and return the streak. BUT : looking at the API cheatsheet (thanks @soma), I've noticed this nextUntil() which I would like to use... but my use always returns 0 If someone can understand why and help me improve on that one, I would appreciate. Thanks ! By the way, feel free (if you have a few minutes) to give me advice on how to improve those foreach() I feel like I'm overusing...
×
×
  • Create New...