Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9225901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:41:41+00:00 2026-06-18T04:41:41+00:00

I am making a game, and came to the part to implement character abilities

  • 0

I am making a game, and came to the part to implement character abilities on the server-side.

So I have an array to hold all character abilities:

$abils = array();

And a class for them:

class Abil{
    private $timing;
    private $func;

    public function __construct($time, $func){
        global $abils;
        $this->timing = $time;
        $this->func = $func;
        array_push($abils,$this);
    }

    public function trigger($time,$params){
        if(preg_match('/^'.$this->timing.'$/',$time)) $this->func($params);
    }
}

$time is the “timing” of the ability, as RegEx. For example, \d\d-0 would be the start of anyone’s turn.
$func is a function to run when the ability is used.

When a certain “timing” is reached (for example, the start of someone’s turn), a global triggerAll() function would be used to trigger all abilities of that timing:

function triggerAll($time,$params = NULL){
    global $abils;
    foreach($abils as $abil) $abil->trigger($time,$params);
}

But then, when triggerAll is called, a fatal error is generated:
Fatal error: Call to undefined method Abil::func()

I suspect this is due to $func not being a METHOD but a PROPERTY which holds a function. Any workarounds?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:41:43+00:00Added an answer on June 18, 2026 at 4:41 am

    Found a workaround: call_user_func

    call_user_func($this->func,$params);
    

    instead of

    $this->func($params);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making some game, and I have made it pretty much all, but not
I am making a game, and have a Game model and a User model.
I am making a game engine using HTML5 canvas, and I have decided to
I'm making a game where you control your character with the arrow keys and
I am making a game of paddle ball, I have designed and scripted ball
I am making a game using the accelerometer, basically my character is at the
I'm making a Game class with a function that makes a window. When I
I'm making a game engine in C++. It is supposed to read all its
I'm making a game and I have stored the map data in a 2-dimensional
I am making a strategy game and came across a kind of problem. Basically,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.