Skip to content

Commit

Permalink
show platforms compability
Browse files Browse the repository at this point in the history
  • Loading branch information
vikoadi committed Feb 21, 2016
1 parent f7c917c commit abde0f8
Show file tree
Hide file tree
Showing 16 changed files with 17 additions and 14 deletions.
7 changes: 5 additions & 2 deletions giantbomb.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func parseJson(jsonStream string, target interface{}) error {
return json.NewDecoder(strings.NewReader(jsonStream)).Decode(target)
}

func Filter(platformsInfo Platforms, filter int) bool {
func GetPlatformsFilter(platformsInfo Platforms) int {
platform := 0
for _, platformInfo := range platformsInfo {
if platformInfo.Abbreviation == "LIN" {
Expand All @@ -147,6 +147,9 @@ func Filter(platformsInfo Platforms, filter int) bool {
if platform == 0 {
platform = 8
}
return platform
}

return (filter & platform) > 0
func Filter(platformsInfo Platforms, filter int) bool {
return (filter & GetPlatformsFilter(platformsInfo)) > 0
}
Binary file added platform1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added platform2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added platform3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added platform4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added platform5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added platform6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added platform7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added platforms1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added platforms2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added platforms3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added platforms4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added platforms5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added platforms6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added platforms7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 12 additions & 12 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (s *Query) AddSearchResults(reply *scopes.SearchReply, query string) error
}

func getDateString(unixDate int64) string {
return time.Unix(unixDate,0).Format ("2 January 2006")
return time.Unix(unixDate, 0).Format("2 January 2006")
}

func (s *Query) registerCategory(reply *scopes.SearchReply, id string, title string, template string, deals cheapshark.Deal, completeDetail bool) error {
Expand All @@ -209,16 +209,16 @@ func (s *Query) registerCategory(reply *scopes.SearchReply, id string, title str
savingsF, _ := d.Savings.Float64()
releaseDate, _ := d.ReleaseDate.Int64()
releaseDateStr := ""
if r := getDateString (releaseDate);releaseDate!=0 {
releaseDateStr=r
if r := getDateString(releaseDate); releaseDate != 0 {
releaseDateStr = r
}

storeIcon := s.getStoreIcon(d.StoreID)
log.Println(storeIcon)
if completeDetail {
if info, err := gb.GetInfo(d.Title); err == nil {
if Filter(info.Platforms, platformFilter) {
addCategorisedGameResult(result, "http://www.cheapshark.com/redirect?dealID="+d.DealID, d.Title, d.Title, d.NormalPrice.String(), d.SalePrice.String(), strconv.Itoa(int(math.Floor(savingsF))), d.MetacriticScore.String(), d.DealRating.String(), info.Image.ThumbURL, info.Image.SmallURL, storeIcon, info.Description, releaseDateStr, "icon.png")
addCategorisedGameResult(result, "http://www.cheapshark.com/redirect?dealID="+d.DealID, d.Title, d.Title, d.NormalPrice.String(), d.SalePrice.String(), strconv.Itoa(int(math.Floor(savingsF))), d.MetacriticScore.String(), d.DealRating.String(), info.Image.ThumbURL, info.Image.SmallURL, storeIcon, info.Description, releaseDateStr, s.getStoreIcon("platform"+strconv.Itoa(GetPlatformsFilter(info.Platforms))))
if err := reply.Push(result); err != nil {
return err
}
Expand Down Expand Up @@ -246,9 +246,9 @@ func addCategorisedGameResult(result *scopes.CategorisedResult, uri string, dndU
result.SetArt(art)
result.Set("bigArt", bigArt)
result.Set("normalPrice", normalPrice)
if (salePrice=="0") {
if salePrice == "0" {
result.Set("salePrice", "<b>FREE</b> from $"+normalPrice)
}else {
} else {
result.Set("salePrice", "<b>$"+salePrice+"</b> from $"+normalPrice)
}
result.Set("uri", uri)
Expand All @@ -264,21 +264,21 @@ func addCategorisedGameResult(result *scopes.CategorisedResult, uri string, dndU
}

attr := []Attr{}
if (savings!="0") {
attr=append(attr, Attr{Value: savings + "%", Icon: storeIcon})
if savings != "0" {
attr = append(attr, Attr{Value: savings + "%", Icon: storeIcon})
}
if (metacriticScore!="0") {
attr=append(attr, Attr{Value: metacriticScore, Icon: "image://theme/starred"})
if metacriticScore != "0" {
attr = append(attr, Attr{Value: metacriticScore, Icon: "image://theme/starred"})
}

result.Set("attributes", attr)

completeAttr := attr

if releaseDate != "" {
completeAttr = append(completeAttr, Attr{Value: "released at "+releaseDate})
completeAttr = append(completeAttr, Attr{Value: "released at " + releaseDate})
}

log.Println(platformsIcon)
if platformsIcon != "" {
completeAttr = append(completeAttr, Attr{Icon: platformsIcon})
}
Expand Down

0 comments on commit abde0f8

Please sign in to comment.