home *** CD-ROM | disk | FTP | other *** search
/ CyberMycha 2003 October / cmycha200310.iso / NHL2004 / NHL2004Demo.exe / fe / nhl / js / loading.js < prev    next >
Text File  |  2003-08-20  |  11KB  |  387 lines

  1. //Copyright (c) 2002 Electronic Arts Inc. All rights reserved.
  2.  
  3. var lArray = new locArray();
  4. var oGameFace           = window.external.GameInterface;
  5. var oLeagueFace         = oGameFace.LeagueServerInterface.LeagueDispatch;
  6. var oManagerFace        = oLeagueFace.ManagerInterface;
  7. var oGameData           = oLeagueFace.ProviderInterface.GameDataInterface;
  8. var oPlayerInfo         = new PlayerInfoObject();
  9. var oAwayTeamPerf            = new TeamPerfObject();
  10. var oHomeTeamPerf            = new TeamPerfObject();
  11.  
  12. var imgPath             = "../../NHL/images2/logos/";
  13. var arenaImgPath         = "../../NHL/images2/screen_images/";
  14.  
  15. document.onselectstart = function() { return false; };
  16.  
  17. function getLocalizedText(bank, msg, bUpper, bDoc)
  18. {
  19.     //955    - "HOT_STREAK"
  20.     //956    - "COLD_STREAK"
  21.     //2093    - "KEY_PLAYERS"
  22.     //2092    - "PLAY_STATUS"
  23.     //85    - "OVERALL"
  24.     //2096    - "BIG_HITTER"
  25.     //597    - "SNIPER"
  26.     //2098    - "HERO"
  27.     //2097    - "BIG_SHOOTER"
  28.     //2793    - "GAME_HINT"
  29.     //2792    - "GAME_BREAKER_METER"
  30.     //2803    - GAME_BREAKER_DESC1
  31.     //2804    - GAME_BREAKER_DESC2
  32.     //2095    - PLAYER_ICONS
  33.     //2102    - BIG_HITTER_DESC
  34.     //2103    - BIG_SHOOTER_DESC
  35.     //2104    - SNIPER_DESC
  36.     //2105    - HERO_DESC
  37.  
  38.     var isUpper;
  39.  
  40.     if (bUpper)
  41.         isUpper = 1;
  42.     else
  43.         isUpper = 0;
  44.  
  45.     if (bDoc)
  46.         document.write(window.external.GameInterface.GetLocalizedText(bank, lArray.lookup(bank, msg), isUpper));
  47.     else
  48.         return (window.external.GameInterface.GetLocalizedText(bank, lArray.lookup(bank, msg), isUpper));
  49. }
  50.  
  51. function prepTeamPerformance()
  52. {
  53.     oManagerFace.GetTeamPerformance(oGameData.HomeTeam, oHomeTeamPerf);
  54.     oManagerFace.GetTeamPerformance(oGameData.AwayTeam, oAwayTeamPerf);
  55. }
  56.  
  57. function setStadiumInfo()
  58. {
  59.     var oTeamInfo = new TeamInfoObject();
  60.     oGameData.GetTeamInfo(0, oTeamInfo);
  61. /*
  62.     if ( oTeamInfo.ArenaName.length == 0 )
  63.     {
  64.         stadiumNameText.innerText = oTeamInfo.CityName.toUpperCase();
  65.     }
  66.     else
  67.     {
  68.         stadiumNameText.innerText = (oTeamInfo.ArenaName + ", " + oTeamInfo.CityName).toUpperCase();
  69.     }
  70. */
  71.     if (parseInt(oTeamInfo.sArenaFile.substring(4,6)) > 50 && parseInt(oTeamInfo.sArenaFile.substring(4,6)) != 63 &&
  72.         parseInt(oTeamInfo.sArenaFile.substring(4,6)) != 65 && parseInt(oTeamInfo.sArenaFile.substring(4,6)) != 68 &&
  73.         parseInt(oTeamInfo.sArenaFile.substring(4,6)) != 84)
  74.     {
  75.         stadiumImg.src = arenaImgPath + "load_arena_99.jpg";    
  76.     }
  77.     else
  78.     {
  79.         stadiumImg.src = arenaImgPath + "load_arena_" + oTeamInfo.sArenaFile.substring(4,6) + ".jpg";    
  80.     }        
  81.     
  82.     //custom team check    
  83.     if (oTeamInfo.ArtID >= 100)
  84.     {
  85.         stadiumImg.src = arenaImgPath + "load_arena_99.jpg";
  86.     }
  87. }
  88.  
  89. function setAwayTeamInfo()
  90. {
  91.     var oTeamInfo = new TeamInfoObject();
  92.     oGameData.GetTeamInfo(1, oTeamInfo);
  93.  
  94.     //set team logo
  95.     awayLogo.src            = imgPath + oTeamInfo.sLogoFile;
  96.     //set team names
  97.     var awayFullName = oTeamInfo.FullName.toString();
  98.     awayNameText.innerText    = awayFullName.toUpperCase();
  99.  
  100.     //set record
  101.     if (oAwayTeamPerf.Games > 0)
  102.     {
  103.         awayRecordText.innerText = oAwayTeamPerf.Wins + " - " + oAwayTeamPerf.Losses + " - " + oAwayTeamPerf.Ties + " - " + oAwayTeamPerf.OTLosses;
  104.     }
  105.     else
  106.     {
  107.         awayRecordText.innerText = "";
  108.     }
  109.     //set overall stat
  110.  
  111.     awayOverallText.innerText = getLocalizedText(0, "OVERALL", true) + ": " + oTeamInfo.Overall;
  112. }
  113.  
  114. function setHomeTeamInfo()
  115. {
  116.     var oTeamInfo = new TeamInfoObject();
  117.     oGameData.GetTeamInfo(0, oTeamInfo);
  118.  
  119.     //set team logo
  120.     homeLogo.src             = imgPath + oTeamInfo.sLogoFile;
  121.     //set team names
  122.     var fullHomeName = oTeamInfo.FullName.toString();
  123.     homeNameText.innerText    = fullHomeName.toUpperCase();
  124.  
  125.     //set record
  126.     if (oHomeTeamPerf.Games > 0)
  127.     {
  128.         homeRecordText.innerText = oHomeTeamPerf.Wins + " - " + oHomeTeamPerf.Losses + " - " + oHomeTeamPerf.Ties + " - " + oHomeTeamPerf.OTLosses;
  129.     }
  130.     else
  131.     {
  132.         homeRecordText.innerText = "";
  133.     }
  134.     //set overall stat
  135.     homeOverallText.innerText = getLocalizedText(0, "OVERALL", true) + ": " + oTeamInfo.Overall;
  136. }
  137.  
  138. function setKeyPlayers()
  139. {
  140.     playerHeaderAway.innerText = getLocalizedText(0, "KEY_PLAYERS", true);
  141.     playerHeaderHome.innerText = getLocalizedText(0, "KEY_PLAYERS", true);
  142.  
  143.     var homePlayerList = oGameData.GetKeyPlayers(0);
  144.     var count = 0;
  145.  
  146.     if (homePlayerList.length != 0)
  147.     {
  148.         // split it and use the player info
  149.         var aPlayerId = homePlayerList.split(",");
  150.  
  151.         for (var i=0; i<aPlayerId.length; i++)
  152.         {
  153.             oGameData.GetPlayerInfo(0, aPlayerId[i], oPlayerInfo);
  154.             document.all["homePlayer" + i].innerText = oPlayerInfo.sName;
  155.             document.all["homePlayerJersey" + i].innerText = oPlayerInfo.nJersey;
  156.             document.all["homePlayerPosition" + i].innerText = oPlayerInfo.sPosition;
  157.  
  158.             //document.all["homePlayerWhite" + i].innerText = oPlayerInfo.sName;
  159.  
  160.             var aImgObj = Array(document.all["homePlayerIconA" + i], document.all["homePlayerIconB" + i], document.all["homePlayerIconC" + i], document.all["homePlayerIconD" + i]);
  161.  
  162.             count = 0;
  163.  
  164.             if (oPlayerInfo.bIsHero)
  165.             {
  166.                 aImgObj[count].src = "../images2/common/icon_hero.gif";
  167.                 count++;
  168.             }
  169.             if (oPlayerInfo.bIsBigShooter)
  170.             {
  171.                 aImgObj[count].src = "../images2/common/icon_shooter.gif";
  172.                 count++;
  173.             }
  174.             if (oPlayerInfo.bIsSniper)
  175.             {
  176.                 aImgObj[count].src = "../images2/common/icon_sniper.gif";
  177.                 count++;
  178.             }
  179.             if (oPlayerInfo.bIsBigHitter)
  180.             {
  181.                 aImgObj[count].src = "../images2/common/icon_hitter.gif";
  182.                 count++;
  183.             }
  184.  
  185.         }
  186.     }
  187.  
  188.     var awayPlayerList = oGameData.GetKeyPlayers(1);
  189.  
  190.     if (awayPlayerList.length != 0)
  191.     {
  192.         aPlayerId = awayPlayerList.split(",");
  193.  
  194.         for (var i=0; i<aPlayerId.length; i++)
  195.         {
  196.             oGameData.GetPlayerInfo(1, aPlayerId[i], oPlayerInfo);
  197.             document.all["awayPlayer" + i].innerText = oPlayerInfo.sName;
  198.             document.all["awayPlayerJersey" + i].innerText = oPlayerInfo.nJersey;
  199.             document.all["awayPlayerPosition" + i].innerText = oPlayerInfo.sPosition;
  200.  
  201.             var aImgObj = Array(document.all["awayPlayerIconA" + i], document.all["awayPlayerIconB" + i], document.all["awayPlayerIconC" + i], document.all["awayPlayerIconD" + i]);
  202.  
  203.             count = 0;
  204.  
  205.             if (oPlayerInfo.bIsHero)
  206.             {
  207.                 aImgObj[count].src = "../images2/common/icon_hero.gif";
  208.                 count++;
  209.             }
  210.             if (oPlayerInfo.bIsBigShooter)
  211.             {
  212.                 aImgObj[count].src = "../images2/common/icon_shooter.gif";
  213.                 count++;
  214.             }
  215.             if (oPlayerInfo.bIsSniper)
  216.             {
  217.                 aImgObj[count].src = "../images2/common/icon_sniper.gif";
  218.                 count++;
  219.             }
  220.             if (oPlayerInfo.bIsBigHitter)
  221.             {
  222.                 aImgObj[count].src = "../images2/common/icon_hitter.gif";
  223.                 count++;
  224.             }
  225.  
  226.         }
  227.     }
  228. }
  229.  
  230. function formatPlayerName( sPlayerName )
  231. {
  232.     var aPlayerName = sPlayerName.split(" ");
  233.     //we'll display players first initial, plus all components of their last name (ie: "Mario De Rosa" --> "M. De Rosa")
  234.     sPlayerName = aPlayerName[0].substring(0, 1) + ". ";
  235.     var aLen = aPlayerName.length;
  236.  
  237.     for( var j = 1; j < aLen; j++ )
  238.     {
  239.         sPlayerName += aPlayerName[j].toUpperCase();
  240.         if( j < aLen - 1 )
  241.         {
  242.             sPlayerName += " ";
  243.         }
  244.     }
  245.  
  246.     return sPlayerName;
  247. }
  248.  
  249. function setPlayerStatus()
  250. {
  251.     playerHeaderAway.innerText = getLocalizedText(0, "PLAYER_STATUS", true);
  252.     playerHeaderHome.innerText = getLocalizedText(0, "PLAYER_STATUS", true);
  253.  
  254.     //key players
  255.     for (var i=0; i<5; i++)
  256.     {
  257.         if (i == oAwayTeamPerf.StreakPlayersNum)
  258.             break;
  259.  
  260.         if (oAwayTeamPerf.StreakPlayers[i].match(getLocalizedText(0, "HOT_STREAK")))
  261.         {
  262.             var sPlayerName = oAwayTeamPerf.StreakPlayers[i].replace(getLocalizedText(0, "HOT_STREAK"), "");
  263.             sPlayerName = formatPlayerName( sPlayerName );
  264.  
  265.             document.all["awayPlayer" + i].innerText = sPlayerName;
  266.  
  267.             //document.all["awayPlayerJersey" + i].innerText = ;
  268.             //document.all["awayPlayerPosition" + i].innerText = ;
  269.  
  270.             document.all["awayPlayerIconA" + i].src = "../images2/common/icon_hot.gif";
  271.         }
  272.         else
  273.         {
  274.             var sPlayerName = oAwayTeamPerf.StreakPlayers[i].replace(getLocalizedText(0, "COLD_STREAK"), "");
  275.             var aPlayerName = sPlayerName.split(" ");
  276.             sPlayerName = formatPlayerName( sPlayerName );
  277.  
  278.             document.all["awayPlayer" + i].innerText = sPlayerName;
  279.  
  280.             //document.all["awayPlayerJersey" + i].innerText = ;
  281.             //document.all["awayPlayerPosition" + i].innerText = ;
  282.  
  283.             document.all["awayPlayerIconA" + i].src = "../images2/common/icon_cold.gif";
  284.         }
  285.     }
  286.  
  287.     //key players
  288.     for (var i=0; i<5; i++)
  289.     {
  290.         if (i == oHomeTeamPerf.StreakPlayersNum)
  291.             break;
  292.  
  293.         if (oHomeTeamPerf.StreakPlayers[i].match(getLocalizedText(0, "HOT_STREAK")))
  294.         {
  295.             var sPlayerName = oHomeTeamPerf.StreakPlayers[i].replace(getLocalizedText(0, "HOT_STREAK"), "");
  296.             var aPlayerName = sPlayerName.split(" ");
  297.             sPlayerName = formatPlayerName( sPlayerName );
  298.  
  299.             document.all["homePlayer" + i].innerText = sPlayerName;
  300.  
  301.             //document.all["homePlayerJersey" + i].innerText = ;
  302.             //document.all["homePlayerPosition" + i].innerText = ;
  303.  
  304.             document.all["homePlayerIconA" + i].src = "../images2/common/icon_hot.gif";
  305.         }
  306.         else
  307.         {
  308.             var sPlayerName = oHomeTeamPerf.StreakPlayers[i].replace(getLocalizedText(0, "COLD_STREAK"), "");
  309.             var aPlayerName = sPlayerName.split(" ");
  310.             sPlayerName = formatPlayerName( sPlayerName );
  311.  
  312.             document.all["homePlayer" + i].innerText = sPlayerName;
  313.  
  314.             //document.all["homePlayerJersey" + i].innerText = ;
  315.             //document.all["homePlayerPosition" + i].innerText = ;
  316.  
  317.             document.all["homePlayerIconA" + i].src = "../images2/common/icon_cold.gif";
  318.         }
  319.     }
  320. }
  321.  
  322. function displayGameHint()
  323. {
  324.     var nRandomNumber = Math.round(Math.random()*parseInt(25));
  325.     gameHint.innerText = getLocalizedText(3, "HINTTEXT" + nRandomNumber);
  326. }
  327.  
  328.  
  329. function TeamInfoObject()
  330. {    
  331.     this.Name = "";
  332.     this.FullName ="";
  333.     this.ArenaName = "";
  334.     this.CityName = "";
  335.     this.sArenaFile = "load_arena_99.jpg";
  336.     this.sLogoFile = "";
  337.     this.Overall = 0;
  338.     this.ArtID = -1;
  339. }
  340.  
  341.  
  342. function TeamPerfObject()
  343. {
  344.     this.Games = -1;
  345.     this.Wins = -1;
  346.     this.Losses = -1;
  347.     this.Ties = -1;
  348.     this.OTLosses = -1;
  349.     this.Points = -1;
  350.     this.GF = -1;
  351.     this.GA = -1;
  352.     this.PP = "";
  353.     this.PK = "";
  354.  
  355.     this.RecentWins = -1;
  356.     this.RecentLosses = -1;
  357.     this.RecentTies = -1;
  358.     this.RecentOTLosses = -1;
  359.  
  360.     this.StreakPlayersNum = 0;
  361.     this.StreakPlayers = new Array();
  362.     this.InjuredPlayersNum = 0;
  363.     this.InjuredPlayers = new Array();
  364.     this.SuspendedPlayersNum = 0;
  365.     this.SuspendedPlayers = new Array();
  366.     for (rosterIndex = 0; rosterIndex < 10; rosterIndex++)
  367.     {
  368.         this.StreakPlayers[rosterIndex] = "";
  369.         this.InjuredPlayers[rosterIndex] = "";
  370.         this.SuspendedPlayers[rosterIndex] = "";
  371.     }
  372. }
  373.  
  374. function PlayerInfoObject()
  375. {
  376.     this.sName = "";
  377.     this.sFullName = "";
  378.     this.nJersey = -1;
  379.     this.sPosition = "";
  380.  
  381.     this.bIsHero = false;
  382.     this.bIsBigShooter = false;
  383.     this.bIsSniper = false;
  384.     this.bIsBigHitter = false;
  385. }
  386.  
  387.