Skip to content
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
17 changes: 14 additions & 3 deletions .paket/Paket.Restore.targets
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
<PaketExePath Condition=" '$(PaketExePath)' == '' ">$(PaketToolsPath)paket.exe</PaketExePath>
<PaketCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketExePath)"</PaketCommand>
<PaketCommand Condition=" '$(OS)' != 'Windows_NT' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</PaketCommand>

<!-- .net core fdd -->
<_PaketExeExtension>$([System.IO.Path]::GetExtension("$(PaketExePath)"))</_PaketExeExtension>
<PaketCommand Condition=" '$(_PaketExeExtension)' == '.dll' ">dotnet "$(PaketExePath)"</PaketCommand>

<!-- no extension is a shell script -->
<PaketCommand Condition=" '$(_PaketExeExtension)' == '' ">"$(PaketExePath)"</PaketCommand>

<PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' AND Exists('$(PaketRootPath)paket.bootstrapper.exe')">$(PaketRootPath)paket.bootstrapper.exe</PaketBootStrapperExePath>
<PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' ">$(PaketToolsPath)paket.bootstrapper.exe</PaketBootStrapperExePath>
<PaketBootStrapperCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketBootStrapperExePath)"</PaketBootStrapperCommand>
Expand Down Expand Up @@ -45,10 +53,10 @@
</PropertyGroup>

<!-- If shasum and awk exist get the hashes -->
<Exec Condition=" '$(PaketRestoreCachedHasher)' != '' " Command="$(PaketRestoreCachedHasher)" ConsoleToMSBuild='true'>
<Exec StandardOutputImportance="Low" Condition=" '$(PaketRestoreCachedHasher)' != '' " Command="$(PaketRestoreCachedHasher)" ConsoleToMSBuild='true'>
<Output TaskParameter="ConsoleOutput" PropertyName="PaketRestoreCachedHash" />
</Exec>
<Exec Condition=" '$(PaketRestoreLockFileHasher)' != '' " Command="$(PaketRestoreLockFileHasher)" ConsoleToMSBuild='true'>
<Exec StandardOutputImportance="Low" Condition=" '$(PaketRestoreLockFileHasher)' != '' " Command="$(PaketRestoreLockFileHasher)" ConsoleToMSBuild='true'>
<Output TaskParameter="ConsoleOutput" PropertyName="PaketRestoreLockFileHash" />
</Exec>

Expand Down Expand Up @@ -114,9 +122,11 @@
<PaketReferencesFileLinesInfo Include="@(PaketReferencesFileLines)" >
<PackageName>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])</PackageName>
<PackageVersion>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])</PackageVersion>
<AllPrivateAssets>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[4])</AllPrivateAssets>
</PaketReferencesFileLinesInfo>
<PackageReference Include="%(PaketReferencesFileLinesInfo.PackageName)">
<Version>%(PaketReferencesFileLinesInfo.PackageVersion)</Version>
<PrivateAssets Condition="%(PaketReferencesFileLinesInfo.AllPrivateAssets) == 'true'">All</PrivateAssets>
</PackageReference>
</ItemGroup>

Expand All @@ -138,9 +148,10 @@
</DotNetCliToolReference>
</ItemGroup>

<!-- Disabled for now until we know what to do with runtime deps - https://github.com/fsprojects/Paket/issues/2964
<PropertyGroup>
<RestoreConfigFile>$(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).NuGet.Config</RestoreConfigFile>
</PropertyGroup>
</PropertyGroup> -->

</Target>

Expand Down
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
language: csharp
sudo: required
dist: trusty # Ubuntu 14.04
dotnet : 2.1.4
env:
- HOME=/home/travis APPDATA=/home/travis LocalAppData=/home/travis


before install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install openssl ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew link --force openssl ; fi

mono:
- 5.0.1

script:
- dotnet build build.proj

branches:
except:
- gh-pages
18 changes: 18 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
image: Visual Studio 2017
install:
- cinst fake -pre
build_script:
# See https://stackoverflow.com/a/12866669/1269722
# Problem is that colors are lost
# Don't blame me but powershell is the bigest crap on earth
- cmd: fake.exe -v run build.fsx

#on_failure:
# - appveyor PushArtifact FAKE.svclog
test: off
environment:
PAKET_BOOTSTRAPPER_TRACE: true

artifacts:
- path: 'release\nuget\*.nupkg'
type: NuGetPackage
31 changes: 31 additions & 0 deletions build.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<DotNetCliToolReference Include="dotnet-fake" Version="5.0.0-*" />
</ItemGroup>

<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<RepoRootDir>$([System.IO.Path]::GetFullPath("$(MSBuildThisFileDirectory)"))</RepoRootDir>
<BuildDependsOn></BuildDependsOn>
<CoreBuildDependsOn></CoreBuildDependsOn>
</PropertyGroup>

<Target Name="Build">
<Exec IgnoreStandardErrorWarningFormat="true" Command='dotnet fake build' WorkingDirectory="$(RepoRootDir)" />
</Target>

<Target Name="Pack">
</Target>

<Target Name="Test">
</Target>

<Target Name="VSTest" DependsOnTargets="Test" />
</Project>
3 changes: 3 additions & 0 deletions docs/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 1.0.0-alpha004 - 2018-03-11
* Static GameInfo data can now be accessed from the GameState - https://github.com/matthid/s2client-dotnet/pull/5

#### 1.0.0-alpha003 - 2017-11-07
* Fix release script

Expand Down
2 changes: 1 addition & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version 5.122.0
version 5.148.0
source https://api.nuget.org/v3/index.json
storage:none

Expand Down
6 changes: 6 additions & 0 deletions src/s2client-fsharp/Instance.fs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ module Instance =

return playerId
}
let getGameInfo (instance:Sc2Instance) = async {
// Do the join command
let! gameInfo, status = ProtbufConnection.getGameInfo instance.Connection
assert (status = Status.InGame)
return gameInfo }

let getObservation disableFog (instance:Sc2Instance) = async {
// Do the join command
let! responseObs, status = ProtbufConnection.getObservation disableFog instance.Connection
Expand Down
8 changes: 8 additions & 0 deletions src/s2client-fsharp/ProtobufConnection.fs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ module ProtbufConnection =
checkError joinGameResponse.Error joinGameResponse.ErrorDetails
return joinGameResponse.PlayerId, response.Status }

let getGameInfo (cl : Sc2Connection) = async {
let request = new SC2APIProtocol.Request()
request.GameInfo <- new RequestGameInfo()
let! response = sendRequest cl request
let gameInfoResponse = response.GameInfo
checkNullAndWarnings response gameInfoResponse
return gameInfoResponse, response.Status }

let getObservation disableFog (cl : Sc2Connection) = async {
let request = new SC2APIProtocol.Request()
request.Observation <- new RequestObservation()
Expand Down
10 changes: 9 additions & 1 deletion src/s2client-fsharp/Sc2Game.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ type GameState =
NewObservation : SC2APIProtocol.ResponseObservation
// more global state
PlayerId : PlayerId
GameInfo : SC2APIProtocol.ResponseGameInfo
}
static member Empty playerId =
{ LastObservation = None
LastActions = []
NewObservation = null
PlayerId = playerId }
PlayerId = playerId
GameInfo = null }

type Sc2Bot = GameState -> SC2APIProtocol.Action list
type Sc2Observer = GameState -> unit
Expand Down Expand Up @@ -142,6 +144,12 @@ module Sc2Game =
| _ -> failwithf "Expected playerId when participant or observer but not when computer. %A" (part,playerId)
)

// Get the static gameInfo
for (playerId, instance, bot) in relevantPlayers do
let! gameInfo = Instance.getGameInfo instance
let state = getState playerId
updateState playerId { state with GameInfo = gameInfo }

// Game loop
while true do
for (playerId, instance, bot) in relevantPlayers do
Expand Down