SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    John 8:24 JREAM's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Flowchart, Repition

    Im trying to figure out how to share the "new User" functions
    with the "Enemy", rather than duplicating them..

    Ive gone through my mind so much how to lay this stuff out but now
    its getting very messy. And I would like to ask anyone for any advice before I drive myself crazy.

    I wish there were a way to Implement functions into an object without instantiating it.

    I also wish that if I am in User, and its instantiated in App, that I could call anything from App inside of User even if its not extended.


  2. #2
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what's the difference between user and enemy? I not sure what your doing cause your post doesn't make all that much sense. However, if enemy is just a relationship between two user objects then you don't have to worry about creating some additional functionality to get access user object methods or properties.
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  3. #3
    John 8:24 JREAM's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The User and Enemy are both real players,
    Enemy only gets a little bit of information the same as users.
    I didnt know if i should try abstract or an interface to make it clearer..

    I dont see very many examples of what people make and the best way to go about it.
    So I am trying to make it up logically as I go without abusing too much repetition.

  4. #4
    John 8:24 JREAM's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I found a solution

    PHP Code:
    class User
    {
        protected function 
    GetUserInfo()
        {
            
    // Process Methods
            
    self::UserRowData();
            
    self::GetEmpire();
            
    self::GetGuildTitle();
            
    self::TrainingPointChecker();
            
    self::CalculateStats();
            
    self::ZeroSafe();
            
    self::ArmorTitles();
        }
        
    // All these methods defined below
    }

    class 
    MyCharacter extends User
    {
        function 
    __construct($userID)
        {
            
    // Compile the Character
            
    $this->GetUserInfo();

            
    // New Objects for Procedures and Setup
            
    $this->Action        = new Action($this);
            
    $this->Inventory    = new Inventory();
            
    $this->Bar            = new Bar($this);
            
        }
        
    }


    class 
    Enemy extends User
    {
        function 
    __construct($userID)
        {
            
    $this->UserRowData();
            
    self::TrainingPointChecker();
            
    self::CalculateStats();

            
        }
        



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •