当前位置: 首页>>代码示例>>PHP>>正文


PHP Team::dtreasury方法代码示例

本文整理汇总了PHP中Team::dtreasury方法的典型用法代码示例。如果您正苦于以下问题:PHP Team::dtreasury方法的具体用法?PHP Team::dtreasury怎么用?PHP Team::dtreasury使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Team的用法示例。


在下文中一共展示了Team::dtreasury方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 public static function create(array $input, array $opts)
 {
     /**
      * Creates a new player.
      *
      * Input: nr, f_pos_id, name, team_id
      **/
     global $rules, $DEA, $T_ALL_PLAYER_NR;
     $lid = get_alt_col('teams', 'team_id', $input['team_id'], 'f_lid');
     setupGlobalVars(T_SETUP_GLOBAL_VARS__LOAD_LEAGUE_SETTINGS, array('lid' => (int) $lid));
     // Load correct $rules for league.
     // Do these fixes because we can't define class statics using string interpolation for $rules.
     self::$T_CREATE_ERROR_MSGS[self::T_CREATE_ERROR__TEAM_FULL] .= " You have filled all {$rules['max_team_players']} available positions.";
     self::$T_CREATE_ERROR_MSGS[self::T_CREATE_ERROR__JM_LIMIT_REACHED] .= " Your team is now able to fill {$rules['journeymen_limit']} positions.";
     $JM = isset($opts['JM']) && $opts['JM'];
     $FREE = isset($opts['free']) && $opts['free'];
     $FORCE = isset($opts['force']) && $opts['force'];
     # When forcing ($FORCE is true) we ignore these errors:
     $ignoreableErrors = array(self::T_CREATE_ERROR__TEAM_FULL, self::T_CREATE_ERROR__POS_LIMIT_REACHED, self::T_CREATE_ERROR__INSUFFICIENT_FUNDS, self::T_CREATE_ERROR__NUMBER_OCCUPIED, self::T_CREATE_ERROR__JM_LIMIT_REACHED, self::T_CREATE_ERROR__INVALID_JM_POS);
     $EXPECTED = self::$createEXPECTED;
     sort($EXPECTED);
     ksort($input);
     // Input error handler
     if (!get_alt_col('teams', 'team_id', (int) $input['team_id'], 'team_id')) {
         return array(self::T_CREATE_ERROR__INVALID_TEAM, null);
     } else {
         $team = new Team((int) $input['team_id']);
     }
     $errors = array(self::T_CREATE_ERROR__UNEXPECTED_INPUT => $EXPECTED !== array_keys($input), self::T_CREATE_ERROR__TEAM_FULL => !$JM && $team->isFull(), self::T_CREATE_ERROR__INVALID_POS => !$team->isPlayerPosValid((int) $input['f_pos_id']), self::T_CREATE_ERROR__POS_LIMIT_REACHED => !$team->isPlayerBuyable((int) $input['f_pos_id']), self::T_CREATE_ERROR__INSUFFICIENT_FUNDS => $team->treasury - ($price = $JM || $FREE ? 0 : self::price((int) $input['f_pos_id'])) < 0, self::T_CREATE_ERROR__INVALID_NUMBER => !in_array($input['nr'], $T_ALL_PLAYER_NR), self::T_CREATE_ERROR__NUMBER_OCCUPIED => $team->isPlayerNumberOccupied((int) $input['nr']), self::T_CREATE_ERROR__JM_LIMIT_REACHED => $JM && $team->isJMLimitReached(), self::T_CREATE_ERROR__INVALID_JM_POS => $JM && $DEA[$team->f_rname]['players'][get_alt_col('game_data_players', 'pos_id', (int) $input['f_pos_id'], 'pos')]['qty'] < 12);
     foreach ($errors as $exitStatus => $halt) {
         if ($halt && !($FORCE && in_array($exitStatus, $ignoreableErrors))) {
             return array($exitStatus, null);
         }
     }
     $input['owned_by_team_id'] = (int) $input['team_id'];
     unset($input['team_id']);
     $input['name'] = "'" . mysql_real_escape_string($input['name']) . "'";
     $input['date_bought'] = 'NOW()';
     $input['type'] = $JM ? PLAYER_TYPE_JOURNEY : PLAYER_TYPE_NORMAL;
     foreach (array('ach_ma', 'ach_st', 'ach_ag', 'ach_av', 'extra_spp') as $f) {
         $input[$f] = 0;
     }
     $query = "INSERT INTO players (" . implode(',', array_keys($input)) . ") VALUES (" . implode(',', array_values($input)) . ")";
     if (mysql_query($query)) {
         $pid = mysql_insert_id();
         $team->dtreasury(-1 * $price);
     } else {
         self::$T_CREATE_SQL_ERROR['query'] = $query;
         self::$T_CREATE_SQL_ERROR['error'] = mysql_error();
         return array(self::T_CREATE_ERROR__SQL_QUERY_FAIL, null);
     }
     SQLTriggers::run(T_SQLTRIG_PLAYER_NEW, array('id' => $pid, 'obj' => (object) array('player_id' => $pid, 'owned_by_team_id' => (int) $input['owned_by_team_id'])));
     # Update PV and TV.
     return array(self::T_CREATE_SUCCESS, $pid);
 }
开发者ID:rythos42,项目名称:naflm,代码行数:55,代码来源:class_player.php

示例2: update

 public function update(array $input)
 {
     /* 
         Updates general match data. 
         
         $input must contain the keys defined in $core_tables, with the exception of the $filter contents below.
     */
     // Verify input
     global $core_tables;
     $filter = array('match_id', 'round', 'f_tour_id', 'locked', 'date_played', 'date_modified', 'date_created', 'team1_id', 'team2_id');
     $EXPECTED = array_diff(array_keys($core_tables['matches']), $filter);
     sort($EXPECTED);
     $PASSED = array_keys($input);
     sort($PASSED);
     if ($PASSED !== $EXPECTED) {
         return false;
     }
     // Input check.
     if ($this->locked || !get_alt_col('coaches', 'coach_id', $input['submitter_id'], 'coach_id')) {
         # If invalid submitter ID (coach ID) then quit.
         return false;
     }
     // Determine if team fan-factors are within the "> 0" limit. If not, don't save the negative fan-factor.
     $team1 = new Team($this->team1_id);
     $team2 = new Team($this->team2_id);
     if ($team1->rg_ff - $this->ffactor1 + $input['ffactor1'] < 0) {
         $input['ffactor1'] = $this->ffactor1;
     }
     if ($team2->rg_ff - $this->ffactor2 + $input['ffactor2'] < 0) {
         $input['ffactor2'] = $this->ffactor2;
     }
     // Entry corrections
     $input['date_played'] = $this->is_played ? 'date_played' : 'NOW()';
     $input['date_modified'] = 'NOW()';
     // Update match entry.
     $query = "UPDATE matches SET " . array_strpack_assoc('%k = %v', $input, ',') . " WHERE match_id = {$this->match_id}";
     if (!mysql_query($query)) {
         return false;
     }
     // Update team treasury
     $team1->dtreasury($input['income1'] - $this->income1);
     $team2->dtreasury($input['income2'] - $this->income2);
     return true;
 }
开发者ID:nicholasmr,项目名称:obblm,代码行数:44,代码来源:class_match.php

示例3: match

                # The status must be set as the "inj" (not agn) field for EVERY match (import) entry.
                # This is because MySQL may pick a random match data entry from which to get the status from.
                $pstatus = $T_INJS_REV[strtoupper($p->status)];
                # Injuries
                foreach (array('ma', 'st', 'ag', 'av', 'ni') as $inj) {
                    $agn = $T_INJS_REV[strtoupper($inj)];
                    while ($p->{$inj}-- > 0) {
                        $status2 &= Match::ImportEntry($pid, array_merge(array_fill_keys(array_merge($T_PMD_ACH, $T_PMD_IR), 0), array_combine($T_PMD_INJ, array($pstatus, $agn, $p->{$inj}-- > 0 ? $agn : NONE))));
                    }
                }
                # Set player achievements
                $status2 &= Match::ImportEntry($pid, array_merge(array_intersect_key((array) $p, array_fill_keys($T_PMD_ACH, null)), array_combine($T_PMD_INJ, array($pstatus, NONE, NONE)), array_fill_keys($T_PMD_IR, 0)));
                status($status2, "Added to '{$t->name}' player '{$p->name}'");
            }
            # Set correct treasury.
            $team->dtreasury($t->treasury * 1000 - $team->treasury);
            // $t->treasury + $delta = XML value
            $team->postImportSync();
        }
        if ($ROLLBACK) {
            status($team->delete(), 'Successfully deleted new team due to error.');
        }
    }
}
title($lng->getTrn('menu/admin_menu/import'));
?>
This page allows you to create a customized team for an existing coach.<br> 
This is useful if you and your league wish to avoid starting from scratch in order to use OBBLM.<br>
<br>
<b>Note</b>: If you discover errors after having imported your team, you can either repair the errors<br> 
via the admin tools in the coach corner, or simply delete the team and import a new.<br>
开发者ID:nicholasmr,项目名称:obblm,代码行数:31,代码来源:admin_import.php


注:本文中的Team::dtreasury方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。