Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ultimate_Football_Manager #4662

Merged
merged 10 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions Games/Ultimate_Football_Manager/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
41 changes: 41 additions & 0 deletions Games/Ultimate_Football_Manager/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# **Ultimate Football Manager**



## **Description 📃**
**Ultimate Football Manager** is an immersive football management simulation game that allows players to step into the shoes of a football club manager. Players can select a team, strategize using various formations, manage their squad, and compete in a league to become the ultimate football champion.

## **Functionalities 🎮**
- **Team Selection:** Choose your favorite team from a variety of leagues.
- **Squad Management:** Assign players to different positions based on their skills and ratings.
- **League Competition:** Compete against other teams in a league format.
- **Match Simulation:** Watch your team's performance in simulated matches.
- **Schedule and Results:** View your team's schedule and track their progress through the season.

<br>

## **How to Play? 🕹️**
1. **Start the Game:** Click the "Start Game" button on the landing page.
2. **Select a League:** Choose a league from the dropdown menu.
3. **Select a Team:** Pick a team from the selected league.
4. **Manage Your Team:** View your team's details, set up formations, and manage the squad.
5. **Play Matches:** Progress through the season by playing matches, viewing results, and adjusting strategies.
6. **Track Progress:** Check league standings, match results, and your team's performance throughout the season.

<br>

## **Screenshots 📸**

<br>

**Team Selection**
![Team Selection Screen](/assets/images/Screenshot%202024-06-19%20at%2014.18.30.png)

**Match Simulation**
![Match Simulation Screen](/assets/images/Screenshot%202024-06-19%20at%2014.18.55%201.png)

**League Standing**
![League Standing Screen](/assets/images/Screenshot%202024-06-19%20at%2014.19.10.png)

<br>

Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
164 changes: 164 additions & 0 deletions Games/Ultimate_Football_Manager/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="/assets/images/football.ico">
<title>Ultimate Football Manager</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<a href="index.html"><h1>Ultimate Football Manager</h1></a>
</header>

<main>
<section id="landing-page" class="section-box">
<div id="buttonBox">
<button type="button" id="start-game">Start New Game</button>
<!-- <button type="button">Load Saved Game</button> -->
</div>
</section>

<section id="team-selection" class="section-box hide">
<div id="teamSel_container">
<h2>Select a team:</h2>
<select name="leagues" id="league-dropdown">
<option value="">--Leagues--</option>
<option value="epl">Premier League</option>
<option value="champ">Championship</option>
<option value="efl1">League 1</option>
<option value="efl2">League 2</option>
</select>
<select name="teams" id="team-dropdown">
<option value="">--Teams--</option>
</select>
<button type="button" id="teamBtn">Finish</button>
</div>
</section>

<section id="main-menu" class="section-box hide">
<div id="mainMenu_btns">
<h2>Team: <span id="team-name"></span></h2>
<button type="button" id="teamPageBtn">Team</button>
<button type="button" id="leaguePageBtn">League Table</button>
<button type="button" id="schedulePageBtn">Schedule</button>
<button type="button" id="nextGameBtn">Next Game</button>
</div>
</section>

<section id="team-page" class="hide">
<div class="tableButtonContainer">
<table id="teamTable">
<thead id="tableHeader">
<tr>
<th>Name</th>
<th>Selection</th>
<th>Pos</th>
<th>Rating</th>
<th>Value</th>
<th>Wage</th>
</tr>
</thead>
</table>
<div id="formationButtons">
<button id="442">4-4-2</button>
<button id="352">3-5-2</button>
<button id="532">5-3-2</button>
<button id="451">4-5-1</button>
<button id="541">5-4-1</button>
</div>
</div>
<button type="button" id="teamMainBtn">Main Menu</button>
</section>

<section id="league-page" class="hide">
<table id="leagueTable">
<thead>
<tr>
<th>Position</th>
<th>Team</th>
<th>P</th>
<th>W</th>
<th>D</th>
<th>L</th>
<th>GF</th>
<th>GA</th>
<th>GD</th>
<th>Pts</th>
</tr>
</thead>
</table>
<button type="button" id="leagueMainBtn">Main Menu</button>
</section>

</section>
<section id="schedule-page" class="hide">
<div id="fixture_page">
<div id="schedule_container">
</div>
<button type="button" id="scheduleMainBtn">Main Menu</button>
</div>
</section>
<section id="history-page" class="hide">
<div>
<div>

</div>
<button type="button" id="historyMainBtn">Main Menu</button>
</div>
</section>

<section id="game-screen" class="hide">
<h2 id="time">0</h2>
<div id="teamLayer">
<h2 id="homeTeam">Home Team</h2>
<div id="scoreDiv">
<h2 id="homeScore">0</h2>
<h2>:</h2>
<h2 id="awayScore">0</h2>
</div>
<h2 id="awayTeam">Away Team</h2>
</div>
<div id="eventLayer">
<p id="homeScorer"></p>
<p id="awayScorer"></p>
</div>
<div id="buttonBox">
<button type="button" id="startGame">Start Game</button>
<!-- <button type="button" id="nextMainBtn" class="hide">Main Menu</button> -->
<button type="button" id="nextResultsBtn" class="hide">Results</button>
</div>
</section>
<section id="results-screen" class="hide">
<div id="results_container">
<table id="resultsTable">
<thead id="resultsHeader">
</thead>
</table>
<button type="button" id="resultsMainBtn">Main Menu</button>
</div>
</section>
</main>


<footer>
<p>&copy; 2024 Ultimate Football Manager. All rights reserved.</p>
</footer>
</body>

<script src="js/playerClass.js"></script>
<script src="js/teamClass.js"></script>

<script src="js/main.js"></script>

<script src="js/fixture.js"></script>
<script src="js/results.js"></script>
<script src="js/leagues.js"></script>

<script src="js/engine.js"></script>
<script src="js/game.js"></script>
<script src="js/teamTable.js"></script>

</html>
157 changes: 157 additions & 0 deletions Games/Ultimate_Football_Manager/js/engine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
const playerVolume = [
{players: 1, lower: 0,
upper: 0.15},
{players: 2, lower: 0.150000000000000001,
upper: 0.3},
{players: 3, lower: 0.30000000000000001,
upper: 0.45},
{players: 4, lower: 0.450000000000000001,
upper: 0.645},
{players: 5, lower: 0.6450000000000000001,
upper: 0.804},
{players: 6, lower: 0.8040000000000000001,
upper: 0.904},
{players: 7, lower: 0.9040000000000000001,
upper: 0.954},
{players: 8, lower: 0.9540000000000000001,
upper: 0.974},
{players: 9, lower: 0.9740000000000000001,
upper: 0.99},
{players: 10, lower: 0.9900000000000000001,
upper: 1}
]

randomNum = (skew) => {
let u = Math.random();
let v = Math.random();
num = Math.pow(u, 1-skew) + (v/3);
return num;
}

// get volume of players for each attack play (att or def)
playerVol = () => {
let rand = Math.random();
let players = 0;
playerVolume.forEach(number => {
if (number.lower <= rand && number.upper >= rand) {
players = number.players;
}
})
return players;
}

// pick players involved in the attack play
pickPlayers = (num,arr,team) => {
let tempHome = [...arr];
let maxArray = num - 1;
let chosen = [];
for (let i = 1; i < num; i++) {
let tempRand = Math.floor(Math.random() * maxArray) + 1;
if (tempRand === maxArray) {
tempRand -= 1;
}
chosen.push(tempHome[tempRand]);
tempHome.splice(tempRand,1);
maxArray--;
}
if(team === "def") {
chosen.push(tempHome[0]);
}
return chosen;
}

// get total rating score for array of players
getTotal = (arr) => {
let total = 0;
arr.forEach(number => {
total += number.rating;
})
return total;
}

// decide if goal - if att score is 60% more than def score
score = (att, def, team) => {
let lastScored = "";
if (att > def * 1.60) {
lastScored = team;
return "GOAL";

} else {
return "NO GOAL";
};
}

// const fs = require("fs");
//chances based on midfield score
chancesGenerator = (team) => {
const teamMid = team.filter(item => item.team_position === "M");
const teamScore = getTotal(teamMid) / teamMid.length / 1000;
// let tempArr = [];
// for (let i = 0; i<=1000; i++) {
// tempArr.push(Math.floor(randomNum(teamScore) * 10));
// }
// fs.writeFile("_"+num+".csv", JSON.stringify(tempArr), (err) =>
// err ? console.error(err) : console.log('Success!'));
return Math.floor(randomNum(teamScore) * 10)
}

// chances times and object
chances = (chances) => {
let chancesArr = [];
for(let i=1; i <= chances; i++) {
let temp = {time: Math.floor(Math.random() * (90 - 0) + 1),
goal: "",
scorer: ""};
chancesArr.push(temp);
}
// sort array by time and return
return chancesArr.sort((a,b) => a.time - b.time);
}

attackPlay = (attTeam, defTeam, chancesObj) => {
chancesObj.forEach(item => {
// get how many players attack and defend for each play
const attPlayers = playerVol();
const defPlayers = playerVol();
// pick players involved in the attack play
const attChosen = pickPlayers(attPlayers, attTeam, "att");
const defChosen = pickPlayers(defPlayers, defTeam, "def");
// get total score for attack play
const attTotal = getTotal(attChosen);
const defTotal = getTotal(defChosen);
// decide if goal
const goalQ = score(attTotal, defTotal, attTeam);
// set goal value in game chance object
item.goal = goalQ;
// assign scorer for game chance from players picked for attacked
if(goalQ === "GOAL") {
item.scorer = attChosen[Math.floor(Math.random()*(attChosen.length - 1))];
}
})
return chancesObj;
}

// GAME
// get home and away teams objects
game = (homeName, homeT, awayName, awayT) => {
// calculate game chances
const homeChances = chancesGenerator(homeT,1);
const awayChances = chancesGenerator(awayT,2);
// calculate times for shots for each team (create object)
let homeGameChance = chances(homeChances);
let awayGameChance = chances(awayChances);
// set attack bonus for home team
const attBns = 100;
// set defense bonuse for home team
const defBns = 50;
// set attack bonus on last 5 games
// console.log(homeT[0].club);
// console.log(awayT[0].club);
// For each attack play, check for goal
const homeChanceObj = attackPlay(homeT, awayT, homeGameChance);
const awayChanceObj = attackPlay(awayT, homeT, awayGameChance);

return {homeName, homeChanceObj, awayName, awayChanceObj};
}

// Randomly generate yellow and red cards for each team
Loading
Loading