collapse collapse

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 156
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Search


Author Topic: WBA Tools  (Read 3579 times)

0 Members and 1 Guest are viewing this topic.

Offline Huckleberry

  • Administrator
  • Hero Member
  • *****
  • Posts: 3357
    • View Profile
WBA Tools
« on: April 24, 2015, 12:13:39 AM »
There is a new menu at the top called WBA Tools.  It's not just a description of the IBL owners (man I make myself laugh sometimes), it's also where you can go for:

  • Contracts Compliance Check - This queries the latest csv files to determine what player contracts violate the WBA Constitution.
  • Player Positions Check - This queries the latest csv files to determine what players don't have a rating at their primary position (against the rules). It also checks to make sure that the player has a rating for at least one position, obviously if a player has no defensive rating anywhere then it's not a violation to have a primary position as the WBA doesn't have a DH. Please note that you can play a player at a position where he doesn't have a rating, he just can't have that as his primary listed position.  This is to ensure that a player's overall and potential ratings are not artificially lowered.  If this were the case then the player's acceptable contract extension range would also be artificially lowered.
  • DFA Status Table - This queries the latest csv files and lists any players that are currently Designated For Assignment.  If a player has less than 7 days left DFA he will be listed with the days left in bold red.  This means that he will be automatically handled by OOTP for the next sim.  NOTE THAT HE MAY BE RELEASED IF YOU DON'T HANDLE IT.
  • Team Export Tracker - This is an export tracker I wrote with a little more functionality than the OOTP OU one.  Plus you can see both the ABL and the IBL.  It looks to see if there's a team export file, if the file is valid or there was an upload error (export files almost always have zero file size if they didn't upload properly, this is what it checks for), and if the file is newer than the latest league file. Note that it can't check to see if the export is actually current in-game, only that it was uploaded after the league file. This means that you could export your team file from an old version of the league after I've uploaded a new one and it will still look valid on this report. I deleted all existing out of date exports in order to start writing this tracker, so no worries if you exported for the previous sim but see "No Export" on the tracker report.
  • Team Export Upload Form - The alternative upload form for those of you having issues exporting via FTP from within the game.
« Last Edit: May 01, 2015, 04:35:16 PM by Huckleberry »

Offline captaincoop17

  • Former Owner
  • Newbie
  • *****
  • Posts: 9
    • View Profile
Re: WBA Tools
« Reply #1 on: April 24, 2015, 06:18:50 AM »
How did you make all of these?

Offline Huckleberry

  • Administrator
  • Hero Member
  • *****
  • Posts: 3357
    • View Profile
Re: WBA Tools
« Reply #2 on: April 24, 2015, 07:15:04 AM »
Wrote PHP scripts to read the csv files (except for #3 which pulls data on the team export files and the league file).  Same way the financial information pages run.

The upload form is just another PHP script that checks to make sure you're uploading a *.ootp file and that it's not too huge.

Offline captaincoop17

  • Former Owner
  • Newbie
  • *****
  • Posts: 9
    • View Profile
Re: WBA Tools
« Reply #3 on: April 24, 2015, 07:49:59 AM »
You think you could walk me through the contract one? It would be really useful for the league I run.

Offline Huckleberry

  • Administrator
  • Hero Member
  • *****
  • Posts: 3357
    • View Profile
Re: WBA Tools
« Reply #4 on: April 24, 2015, 08:02:16 AM »
I can do better than walk you through it.

Code: [Select]
<?php

if (($handle fopen('PATH TO CSV DIRECTORY GOES HERE/players.csv''r')) === false) {
    die(
'Error opening file');
}

$headers fgetcsv($handle);
$pl_array = array();

while (
$row fgetcsv($handle)) {
$pl_array[$row[0]] = array_combine($headers$row);
}

fclose($handle);

/*  SETTING PLAYERS AND THEIR ORGANIZATIONS (ORG NUMBERS) ARRAY */

$plys_array2 = array();
$cnt=0;

foreach(
$pl_array as $plkey => $plkeyval) {
    if(
$plkeyval['organization_id'] != 0) {
        foreach(
$plkeyval as $key2 => $val2) {
            if(
substr($key209) == 'player_id' || substr($key2010) == 'first_name' || substr($key209) == 'last_name' || substr($key2015) == 'organization_id') {
                
$plys_array2[$plkey][$key2] = $val2;
            }
        }
        
$cnt++;
    }
}

unset(
$pl_array);

/*  ADDING ORGANIZATION MAJOR LEAGUE TEAM NAME TO ARRAY */

if (($handle fopen('PATH TO CSV DIRECTORY GOES HERE/teams.csv''r')) === false) {
    die(
'Error opening file');
}

$headers fgetcsv($handle);
$tm_arrayi = array();

while (
$row fgetcsv($handle)) {
$tm_arrayi[$row[0]] = array_combine($headers$row);
}

fclose($handle);

foreach(
$plys_array2 as $plkey => $plkeyval) {
    
$plys_array2[$plkey]['team_name'] = $tm_arrayi[$plys_array2[$plkey]['organization_id']]['name']." ".$tm_arrayi[$plys_array2[$plkey]['organization_id']]['nickname'];
    
$plys_array2[$plkey]['player_name'] = $plys_array2[$plkey]['first_name']." ".$plys_array2[$plkey]['last_name'];
}

unset(
$tm_arrayi);

foreach(
$plys_array2 as $plkey => $plkeyval) {
    unset(
$plys_array2[$plkey]['organization_id']);
    unset(
$plys_array2[$plkey]['first_name']);
    unset(
$plys_array2[$plkey]['last_name']);
}

/* SET PLAYER, TEAM NAME, CONTRACT YEARS, AND SALARIES ARRAY */

if (($handle fopen('PATH TO CSV DIRECTORY GOES HERE/players_contract.csv''r')) === false) {
    die(
'Error opening file');
}

$headers fgetcsv($handle);
$pls_array = array();
$pc_arrayi = array();

while (
$row fgetcsv($handle)) {
$pc_arrayi[$row[0]] = array_combine($headers$row);
}

fclose($handle);

foreach(
$plys_array2 as $plkey => $plkeyval) {
    foreach(
$plkeyval as $key2 => $val2) {
            if(
substr($key209) == 'player_id') {
$pls_array[$plkey] = $val2;
}
}
}

foreach(
$pc_arrayi as $pckey => $pckeyval) {
    if(
in_array($pckeyval['player_id'], $pls_array)) {
        foreach(
$pckeyval as $key2 => $val2) {
            if(
substr($key206) == 'salary') {
                
$plys_array2[$pckey][$key2] = $val2;
            }
        }
    }
}

unset(
$pc_arrayi);

/* SET ILLEGAL CONTRACT VALUE TO 0 */

foreach($pls_array as $plkey => $plkeyval) {
    
$plys_array2[$plkey]['i_c'] = 0;
}

/* SET EXTENSION YEARS AND SALARIES INTO ARRAY */

if (($handle fopen('PATH TO CSV DIRECTORY GOES HERE/players_contract_extension.csv''r')) === false) {
    die(
'Error opening file');
}

$headers fgetcsv($handle);
$pce_arrayi = array();

while (
$row fgetcsv($handle)) {
$pce_arrayi[$row[0]] = array_combine($headers$row);
}

fclose($handle);

foreach(
$pce_arrayi as $pckey => $pckeyval) {
    if(
in_array($pckeyval['player_id'], $pls_array)) {
        foreach(
$pckeyval as $key2 => $val2) {
            if(
substr($key206) == 'salary') {
                
$plys_array2[$pckey]['e_'.$key2] = $val2;
            }
        }
    }
}

unset(
$pc_arrayi);

/* SET ILLEGAL CONTRACT REASON TO 0 */

foreach($pls_array as $plkey => $plkeyval) {
    
$plys_array2[$plkey]['i_c_r'] = "N/A";
}

/* CHECK FOR CONTRACT LENGTH VIOLATION */

foreach($plys_array2 as $plkey => $plkeyval) {
    if(
$plys_array2[$plkey]['salary6'] > 0) {
$plys_array2[$plkey]['i_c'] = 1;
$plys_array2[$plkey]['i_c_r'] = "Contract Length";
}
}

/* CHECK FOR EXTENSION LENGTH VIOLATION */

foreach($plys_array2 as $plkey => $plkeyval) {
    if(
$plys_array2[$plkey]['e_salary6'] > 0) {
$plys_array2[$plkey]['i_c'] = 1;
if($plys_array2[$plkey]['i_c_r'] == "N/A") {
$plys_array2[$plkey]['i_c_r'] = "Extension Length";
}
else {
$plys_array2[$plkey]['i_c_r'] = $plys_array2[$plkey]['i_c_r'].", Extension Length";
}
}
}

/* CHECK FOR CONTRACT ANNUAL SALARY DECREASE VIOLATION */

foreach($plys_array2 as $plkey => $plkeyval) {
    if((
$plys_array2[$plkey]['salary0'] > $plys_array2[$plkey]['salary1'] && $plys_array2[$plkey]['salary1'] > 0) || ($plys_array2[$plkey]['salary1'] > $plys_array2[$plkey]['salary2'] && $plys_array2[$plkey]['salary2'] > 0) || ($plys_array2[$plkey]['salary2'] > $plys_array2[$plkey]['salary3'] && $plys_array2[$plkey]['salary3'] > 0) || ($plys_array2[$plkey]['salary3'] > $plys_array2[$plkey]['salary4'] && $plys_array2[$plkey]['salary4'] > 0) || ($plys_array2[$plkey]['salary4'] > $plys_array2[$plkey]['salary5'] && $plys_array2[$plkey]['salary5'] > 0)) {
$plys_array2[$plkey]['i_c'] = 1;
if($plys_array2[$plkey]['i_c_r'] == "N/A") {
$plys_array2[$plkey]['i_c_r'] = "Annual Decrease";
}
else {
$plys_array2[$plkey]['i_c_r'] = $plys_array2[$plkey]['i_c_r'].", Annual Decrease";
}
}
}

/* CHECK FOR EXTENSION ANNUAL SALARY DECREASE VIOLATION */

foreach($plys_array2 as $plkey => $plkeyval) {
    if((
$plys_array2[$plkey]['e_salary0'] > $plys_array2[$plkey]['e_salary1'] && $plys_array2[$plkey]['e_salary1'] > 0) || ($plys_array2[$plkey]['e_salary1'] > $plys_array2[$plkey]['e_salary2'] && $plys_array2[$plkey]['e_salary2'] > 0) || ($plys_array2[$plkey]['e_salary2'] > $plys_array2[$plkey]['e_salary3'] && $plys_array2[$plkey]['e_salary3'] > 0) || ($plys_array2[$plkey]['e_salary3'] > $plys_array2[$plkey]['e_salary4'] && $plys_array2[$plkey]['e_salary4'] > 0) || ($plys_array2[$plkey]['e_salary4'] > $plys_array2[$plkey]['e_salary5'] && $plys_array2[$plkey]['e_salary5'] > 0)) {
$plys_array2[$plkey]['i_c'] = 1;
if($plys_array2[$plkey]['i_c_r'] == "N/A") {
$plys_array2[$plkey]['i_c_r'] = "Extension Annual Decrease";
}
else {
$plys_array2[$plkey]['i_c_r'] = $plys_array2[$plkey]['i_c_r'].", Extension Annual Decrease";
}
}
}

/* CHECK FOR CONTRACT EXCESSIVE ANNUAL SALARY INCREASE VIOLATION */

foreach($plys_array2 as $plkey => $plkeyval) {
    if((
$plys_array2[$plkey]['salary1'] > 1.1*$plys_array2[$plkey]['salary0']) || ($plys_array2[$plkey]['salary2'] > 1.1*$plys_array2[$plkey]['salary1']) || ($plys_array2[$plkey]['salary3'] > 1.1*$plys_array2[$plkey]['salary2']) || ($plys_array2[$plkey]['salary4'] > 1.1*$plys_array2[$plkey]['salary3']) || ($plys_array2[$plkey]['salary5'] > 1.1*$plys_array2[$plkey]['salary4'])) {
$plys_array2[$plkey]['i_c'] = 1;
if($plys_array2[$plkey]['i_c_r'] == "N/A") {
$plys_array2[$plkey]['i_c_r'] = "Excessive Annual Increase";
}
else {
$plys_array2[$plkey]['i_c_r'] = $plys_array2[$plkey]['i_c_r'].", Excessive Annual Increase";
}
}
}

/* CHECK FOR EXTENSION EXCESSIVE ANNUAL SALARY INCREASE VIOLATION */

foreach($plys_array2 as $plkey => $plkeyval) {
    if((
$plys_array2[$plkey]['e_salary1'] > 1.1*$plys_array2[$plkey]['e_salary0']) || ($plys_array2[$plkey]['e_salary2'] > 1.1*$plys_array2[$plkey]['e_salary1']) || ($plys_array2[$plkey]['e_salary3'] > 1.1*$plys_array2[$plkey]['e_salary2']) || ($plys_array2[$plkey]['e_salary4'] > 1.1*$plys_array2[$plkey]['e_salary3']) || ($plys_array2[$plkey]['e_salary5'] > 1.1*$plys_array2[$plkey]['e_salary4'])) {
$plys_array2[$plkey]['i_c'] = 1;
if($plys_array2[$plkey]['i_c_r'] == "N/A") {
$plys_array2[$plkey]['i_c_r'] = "Extension Excessive Annual Increase";
}
else {
$plys_array2[$plkey]['i_c_r'] = $plys_array2[$plkey]['i_c_r'].", Extension Excessive Annual Increase";
}
}
}

/*  ADDING ORGANIZATION IDs BACK TO ARRAY */

if (($handle fopen('PATH TO CSV DIRECTORY GOES HERE/players.csv''r')) === false) {
    die(
'Error opening file');
}

$headers fgetcsv($handle);
$pl_arrayi = array();

while (
$row fgetcsv($handle)) {
$pl_arrayi[$row[0]] = array_combine($headers$row);
}

fclose($handle);

foreach(
$plys_array2 as $plkey => $plkeyval) {
    
$plys_array2[$plkey]['organization_id'] = $pl_arrayi[$plkey]['organization_id'];
}

unset(
$pl_arrayi);

/* DEFINE NEW ARRAY WITH ONLY ILLEGAL CONTRACTS */

$ic_array = array();

foreach(
$plys_array2 as $plkey => $plkeyval) {
    if (
$plys_array2[$plkey]['i_c'] == 1) {
        foreach(
$plkeyval as $key2 => $val2) {
$ic_array[$plkey][$key2] = $val2;
}
}
}

unset(
$plys_array2);

/*  SORT ARRAY BY TEAM NAME */

uasort($ic_array, function($a$b) {
    return 
strcmp($a['team_name'], $b['team_name']);
});

echo 
"<strong>Illegal WBA Contracts Table</strong> - Empty if none found:
<p>
<div class=\"YOUR STYLE CSS TABLE CLASS NAME GOES HERE\" >
<table>
<tr><th>Team</th><th>Name</th><th>Reason</th></tr>
"
;

foreach(
$ic_array as $ickey => $ickeyval) {
    echo 
"<td style=\"text-align:left\"><a href=\"WWW PATH TO ONLINE OOTP REPORTS GOES HERE/news/html/teams/team_".$ic_array[$ickey]['organization_id'].".html\">".$ic_array[$ickey]['team_name']."</td><td style=\"text-align:left\"><a href=\"WWW PATH TO ONLINE OOTP REPORTS GOES HERE/news/html/players/player_".$ic_array[$ickey]['player_id'].".html\">".$ic_array[$ickey]['player_name']."</td><td style=\"text-align:left\">".$ic_array[$ickey]['i_c_r']."</td></tr>
"
;
}


echo 
"</table>
</div>
<p>
<p>"
;

?>

That's the code.  Now it should be noted that you see no header or other information because the code is written to be embedded into this forum software mod.  So the code is only for the section of the page you see that has the table output.  Let me know if you have any questions.

And no mocking my terribly inefficient coding skills if there are any programmers in the league.  I taught myself, not that you couldn't tell.  Plus I left artifacts of previous algorithms in the code in case I need to go back to an old method.

Oh yeah, almost forgot.  Copyright 2015 WBA and me personally blah, blah, blah.
« Last Edit: April 24, 2015, 08:05:28 AM by Huckleberry »

Offline captaincoop17

  • Former Owner
  • Newbie
  • *****
  • Posts: 9
    • View Profile
Re: WBA Tools
« Reply #5 on: April 24, 2015, 02:36:14 PM »
Where do I put this script on the server?

Offline Huckleberry

  • Administrator
  • Hero Member
  • *****
  • Posts: 3357
    • View Profile
Re: WBA Tools
« Reply #6 on: April 24, 2015, 02:38:20 PM »
You can put it anywhere on your server but you have to edit the parts that say "GOES HERE" with your particular information.

Offline CLK

  • Former Owner
  • Newbie
  • *****
  • Posts: 28
    • View Profile
Re: WBA Tools
« Reply #7 on: April 24, 2015, 02:50:38 PM »
I give props to you and your coding abilities. I taught myself a bit of coding and web design years ago. It wasn't the best but I felt proud that I did it all on my own.  Good job Huck!
CLK -- Bogota Condors GM

Offline APMP

  • Team Owner
  • Sr. Member
  • *****
  • Posts: 324
  • See ball, hit ball, home run.
    • View Profile
Re: WBA Tools
« Reply #8 on: April 25, 2015, 04:58:23 PM »
Nicely done.

Offline Huckleberry

  • Administrator
  • Hero Member
  • *****
  • Posts: 3357
    • View Profile
Re: WBA Tools
« Reply #9 on: May 03, 2015, 08:44:06 PM »
DFA check has been added.  Also the contract check tool now verifies that the contract year is later than 2100 so that the contracts that OOTP automatically assigned are ignored.  The contract check has also been modified to check for the new required team option buyout amount.

Offline Huckleberry

  • Administrator
  • Hero Member
  • *****
  • Posts: 3357
    • View Profile
Re: WBA Tools
« Reply #10 on: August 22, 2016, 10:05:11 AM »
Added a few things, some mentioned elsewhere.

  • Latest OOTP News block on the right of most forum pages.  This pulls straight from the news feed in-game via the csv exports.  This one requires some minor editing of the csv file after export (basically deleting everything except the relevant news items from the previous week) so may lag from time to time.  Otherwise the messages.csv file is way too large for me to want to upload it after each sim.
  • Pennants page as discussed elsewhere. All pennants are under the WBA History menu, each owner's forum profile page now lists any pennants they've won.
  • Waiver wire and trading block page under the WBA Tools menu.  At first I wanted this somewhere on the front page but the loading time is too slow because of all the lookups it has to do in the csv files.

While you could of course access the waiver wire and trading block via the HTML reports, I like having frequently accessed features in one spot.  Not to mention, now if you want to put someone on the trading block but don't have time to make a forum post, he will still be listed on that page so other teams that are looking for trade partners will see that information.
« Last Edit: August 22, 2016, 10:21:36 AM by Huckleberry »

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal