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

Feature/trade route search #168

Open
wants to merge 34 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1179d26
Fix notifications cleaning
Kern046 Aug 19, 2017
cc0ef45
Fix hourly resources update when the base has the bonus resources qua…
Kern046 Aug 19, 2017
99bcaca
Fix player bonus loading
Kern046 Aug 20, 2017
09babd8
Fix trade platform transactions accepting
Kern046 Aug 22, 2017
6e91f54
Refactor search method in commercial route manager and repository
Kern046 Aug 20, 2017
f639d21
Create new ajax route for trade route search
Kern046 Aug 20, 2017
f4875ab
Remove old search in spatioport template
Kern046 Aug 20, 2017
cb76ac6
Implement Ajax call on route search submit and render results
Kern046 Aug 20, 2017
2020b00
Update gulp dependencies
Kern046 Aug 21, 2017
696da13
Implement a spinner component for loading
Kern046 Aug 21, 2017
9c5f047
Stabilize the search results animation and implement a lock on the bu…
Kern046 Aug 21, 2017
e07a3f1
Properly refactor the trade components style in dedicated less file
Kern046 Aug 21, 2017
8be8a2b
Add price and income data to the routes search JSON
Kern046 Aug 21, 2017
b7258db
Implement the proposal module in the results list
Kern046 Aug 21, 2017
4893d74
Implement JSON serialization of a commercial route
Kern046 Aug 21, 2017
f371576
Implement ajax action for route proposal
Kern046 Aug 21, 2017
d06abc8
Implement selectors in spatioport number boxes
Kern046 Aug 21, 2017
4a86d78
Return JSON responses when an error occurs after an ajax call
Kern046 Aug 21, 2017
8a24c28
Implement the ajax call for route proposal
Kern046 Aug 21, 2017
7a4c8ab
Implement private message option when proposing a route
Kern046 Aug 22, 2017
860b33e
Implement style for the textarea field on route proposal module
Kern046 Aug 22, 2017
d5fe07f
Implement message option in proposal ajax call
Kern046 Aug 22, 2017
78231eb
Add cookie parameters for the route search form
Kern046 Aug 22, 2017
5b50b49
Fix the multi-cookie writing in HTTP responses according to RFC6265
Kern046 Aug 22, 2017
0ecebcf
Store the route search form parameters in cookies
Kern046 Aug 22, 2017
1aae18d
Use the stored cookie parameters or default to display the route sear…
Kern046 Aug 22, 2017
6422e94
Fix the route search with no faction selected
Kern046 Aug 22, 2017
fce7b8e
Release the lock on search form once an error has happened
Kern046 Aug 22, 2017
6d49c4e
Fill the factions checkboxes by default in routes search form
Kern046 Aug 22, 2017
5157ded
Add a security margin in the proposal panel CSS
Kern046 Aug 22, 2017
a826e26
Fix displayed data editing on proposal success
Kern046 Aug 22, 2017
9224f6b
Set the sector number with map link in the search results, and standa…
Kern046 Aug 22, 2017
2527154
Remove previous style
Kern046 Sep 29, 2017
12b90f5
Fix module display method
Kern046 Sep 29, 2017
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
Prev Previous commit
Next Next commit
Refactor search method in commercial route manager and repository
Kern046 committed Aug 22, 2017
commit 6e91f545a270030dd111b6b3efda6cfc0f15128c
14 changes: 14 additions & 0 deletions system/Modules/Athena/Manager/CommercialRouteManager.php
Original file line number Diff line number Diff line change
@@ -130,6 +130,20 @@ public function countBaseActiveRoutes($baseId)
{
return $this->entityManager->getRepository(CommercialRoute::class)->countBaseActiveRoutes($baseId);
}

/**
*
* @param OrbitalBase $base
* @param int $playerId
* @param array $factions
* @param int $min
* @param int $max
* @return array
*/
public function searchRoutes(OrbitalBase $base, $playerId, $factions, $min, $max)
{
return $this->entityManager->getRepository(CommercialRoute::class)->searchRoutes($base, $playerId, $factions, $min, $max);
}

/**
* @param CommercialRoute $commercialRoute
36 changes: 36 additions & 0 deletions system/Modules/Athena/Repository/CommercialRouteRepository.php
Original file line number Diff line number Diff line change
@@ -283,6 +283,42 @@ public function countBaseRoutes($baseId)
$query->execute(['base_id' => $baseId, 'distant_base_id' => $baseId]);
return (int) $query->fetch()['nb_routes'];
}

public function searchRoutes($base, $playerId, $factions, $min, $max)
{
$statement = $this->connection->prepare('SELECT
pa.rColor AS playerColor,
pa.avatar AS playerAvatar,
pa.name AS playerName,
ob.name AS baseName,
ob.rPlace AS rPlace,
(FLOOR(SQRT(POW(? - s.xPosition, 2) + POW(? - s.yPosition, 2)))) AS distance
FROM orbitalBase AS ob
LEFT JOIN player AS pa
ON ob.rPlayer = pa.id
LEFT JOIN place AS p
ON ob.rPlace = p.id
LEFT JOIN system AS s
ON p.rSystem = s.id
LEFT JOIN sector AS se
ON s.rSector = se.id
WHERE
pa.id != ?
AND ob.levelSpatioport > 0
AND (FLOOR(SQRT(POW(? - s.xPosition, 2) + POW(? - s.yPosition, 2)))) >= ?
AND (FLOOR(SQRT(POW(? - s.xPosition, 2) + POW(? - s.yPosition, 2)))) <= ?
AND pa.rColor in (' . implode(',', $factions) . ')
ORDER BY distance DESC
LIMIT 0, 40'
);
$statement->execute([
$base->xSystem, $base->ySystem,
$playerId,
$base->xSystem, $base->ySystem, $min,
$base->xSystem, $base->ySystem, $max
]);
return $statement->fetchAll();
}

/**
* @param CommercialRoute $commercialRoute